Commit e07cfc0
committed
Do not read a rising loss as evidence of convergence
The CUSUM charged kappa - z_t per step, so a step that made the loss
worse contributed kappa + |z_t|. A diverging fit therefore reached the
threshold faster than a converged one and stopped reporting the opposite
of the truth: a loss increasing by one unit a step raised 'converged' as
soon as the monitor armed. The same term let a short burst of reversals,
or one heavy-tailed spike, carry most of the distance to h on a trace
that was still improving.
Steps that worsen the loss now count as zero improvement rather than
negative improvement, and when the threshold is reached while the loss is
trending up the run is reported as diverging. Because max(z, 0) removes
the mass that a symmetric z contributed below zero, kappa has to exceed
E[max(z, 0)] to accumulate at all; the defaults are recalibrated to
kappa=0.5, h=10, which reproduces the previous operating point (worst
family false-positive rate 0.8%, detection 100%, median delay 74 steps).
The scale update is winsorized on the same bound as z, so a single spike
no longer inflates sigma for hundreds of steps, and a non-finite
successive difference is skipped instead of poisoning the estimate
permanently. Constructor arguments are checked for finiteness: NaN
previously passed every guard and silently disabled the stop rule, and a
zero or negative sigma_floor either crashed on a constant loss or flipped
the sign of z. A loss that stays non-finite now stops the fit, since
pm.fit aborts on NaN but runs to completion on +inf.1 parent d1efc85 commit e07cfc0
2 files changed
Lines changed: 118 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
177 | 185 | | |
178 | 186 | | |
179 | 187 | | |
180 | 188 | | |
181 | 189 | | |
| 190 | + | |
| 191 | + | |
182 | 192 | | |
183 | 193 | | |
184 | 194 | | |
185 | 195 | | |
186 | 196 | | |
187 | 197 | | |
188 | 198 | | |
189 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
190 | 202 | | |
191 | | - | |
| 203 | + | |
| 204 | + | |
192 | 205 | | |
193 | 206 | | |
194 | 207 | | |
195 | 208 | | |
196 | 209 | | |
197 | 210 | | |
198 | | - | |
199 | | - | |
200 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
201 | 216 | | |
202 | 217 | | |
203 | 218 | | |
| |||
209 | 224 | | |
210 | 225 | | |
211 | 226 | | |
212 | | - | |
213 | | - | |
| 227 | + | |
| 228 | + | |
214 | 229 | | |
215 | 230 | | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
219 | | - | |
220 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
221 | 243 | | |
222 | 244 | | |
223 | | - | |
224 | | - | |
| 245 | + | |
| 246 | + | |
225 | 247 | | |
226 | 248 | | |
227 | 249 | | |
| |||
230 | 252 | | |
231 | 253 | | |
232 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
233 | 258 | | |
234 | 259 | | |
235 | 260 | | |
236 | 261 | | |
| 262 | + | |
237 | 263 | | |
238 | 264 | | |
239 | 265 | | |
| |||
245 | 271 | | |
246 | 272 | | |
247 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
248 | 279 | | |
249 | 280 | | |
250 | 281 | | |
| |||
262 | 293 | | |
263 | 294 | | |
264 | 295 | | |
265 | | - | |
| 296 | + | |
| 297 | + | |
266 | 298 | | |
267 | 299 | | |
268 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
269 | 303 | | |
| 304 | + | |
270 | 305 | | |
271 | 306 | | |
272 | | - | |
| 307 | + | |
273 | 308 | | |
274 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
275 | 315 | | |
276 | 316 | | |
277 | 317 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
160 | 223 | | |
161 | 224 | | |
162 | 225 | | |
| |||
0 commit comments