Commit 69140b5
committed
Fix the two piecewise-linear regression calculation
#66
The current implementation of the regression calculation has these flaws:
When processing (x[0], y[0]), L1 must be any line through (x[0], y[0]) which meets
L2 at a point (x’, y’) where x[0] < x' < x[1]. L1 has no error.
When processing (x[n - 2], y[n - 2]), L2 must be any line through (x[n - 1], y[n - 1])
which meets L1 at a point (x’, y’) where x[n - 2] < x' < x[n - 1]. L2 has no error.
The lambda calculation is incorrect. It includes a term called H which is equal
to C - I. Looking at the algorithm of Kundu/Ubhaya, this should be just C.
lambda should to be used with calculating L1 and (1 - lambda) should to be used
with calculating L2. Currently (1 - lambda) is used in calculating L1 and L2.
The current calculation has this condition if (t1 != t2) continue; This condition
is almost always true even if t1 and t2 are essentiallyEqual.1 parent 1a99525 commit 69140b5
2 files changed
+34
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
166 | | - | |
| 165 | + | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| |||
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
216 | | - | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
246 | 252 | | |
247 | 253 | | |
248 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
249 | 270 | | |
250 | 271 | | |
251 | 272 | | |
| |||
330 | 351 | | |
331 | 352 | | |
332 | 353 | | |
| 354 | + | |
333 | 355 | | |
334 | 356 | | |
335 | | - | |
| 357 | + | |
336 | 358 | | |
337 | 359 | | |
338 | 360 | | |
| |||
373 | 395 | | |
374 | 396 | | |
375 | 397 | | |
376 | | - | |
| 398 | + | |
377 | 399 | | |
378 | 400 | | |
| 401 | + | |
379 | 402 | | |
380 | | - | |
| 403 | + | |
381 | 404 | | |
382 | 405 | | |
383 | 406 | | |
384 | 407 | | |
385 | | - | |
| 408 | + | |
| 409 | + | |
386 | 410 | | |
387 | 411 | | |
388 | 412 | | |
| |||
402 | 426 | | |
403 | 427 | | |
404 | 428 | | |
405 | | - | |
| 429 | + | |
406 | 430 | | |
407 | 431 | | |
408 | 432 | | |
| |||
0 commit comments