regress: speed up range expansion in robust regression
Instead of repeatedly expanding the range of b with the same increment, double the range on each iteration to speed up the expansion. Also, add a sanity check for the interval.
This commit is contained in:
parent
e118b9b1e8
commit
c2944d8727
1 changed files with 9 additions and 15 deletions
22
regress.c
22
regress.c
|
@ -566,23 +566,17 @@ RGR_FindBestRobustRegression
|
||||||
Estimate standard deviation of b and expand range about b based
|
Estimate standard deviation of b and expand range about b based
|
||||||
on that. */
|
on that. */
|
||||||
sb = sqrt(s2 * W/V);
|
sb = sqrt(s2 * W/V);
|
||||||
if (sb > tol) {
|
incr = MAX(sb, tol);
|
||||||
incr = 3.0 * sb;
|
|
||||||
} else {
|
|
||||||
incr = 3.0 * tol;
|
|
||||||
}
|
|
||||||
|
|
||||||
blo = b;
|
|
||||||
bhi = b;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Make sure incr is significant to blo and bhi */
|
incr *= 2.0;
|
||||||
while (bhi + incr == bhi || blo - incr == blo) {
|
|
||||||
incr *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
blo -= incr;
|
/* Give up if the interval is too large */
|
||||||
bhi += incr;
|
if (incr > 100.0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
blo = b - incr;
|
||||||
|
bhi = b + incr;
|
||||||
|
|
||||||
/* We don't want 'a' yet */
|
/* We don't want 'a' yet */
|
||||||
eval_robust_residual(x + start, y + start, n_points, blo, &a, &rlo);
|
eval_robust_residual(x + start, y + start, n_points, blo, &a, &rlo);
|
||||||
|
|
Loading…
Reference in a new issue