regress: fix robust regression
The bisection always terminated after one iteration. Change the code to
check if the middle is different from the lower and upper limits as
suggested in the original recipe.
This fixes commit b14689d59b
.
This commit is contained in:
parent
7fb7f95979
commit
e118b9b1e8
1 changed files with 3 additions and 1 deletions
|
@ -594,6 +594,8 @@ RGR_FindBestRobustRegression
|
|||
/* OK, so the root for b lies in (blo, bhi). Start bisecting */
|
||||
do {
|
||||
bmid = 0.5 * (blo + bhi);
|
||||
if (!(blo < bmid && bmid < bhi))
|
||||
break;
|
||||
eval_robust_residual(x + start, y + start, n_points, bmid, &a, &rmid);
|
||||
if (rmid == 0.0) {
|
||||
break;
|
||||
|
@ -606,7 +608,7 @@ RGR_FindBestRobustRegression
|
|||
} else {
|
||||
assert(0);
|
||||
}
|
||||
} while ((bhi - blo) > tol && (bmid - blo) * (bhi - bmid) > 0.0);
|
||||
} while (bhi - blo > tol);
|
||||
|
||||
*b0 = a;
|
||||
*b1 = bmid;
|
||||
|
|
Loading…
Reference in a new issue