From: Miroslav Lichvar Date: Tue, 14 Dec 2010 16:00:53 +0000 (+0100) Subject: Divide regression weights by stddev instead of minimum distance X-Git-Tag: 1.25-pre1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c88801065f351af312667b2cab3ab7853c8f3bc8;p=thirdparty%2Fchrony.git Divide regression weights by stddev instead of minimum distance This improves accuracy with large but stable network delays. --- diff --git a/sourcestats.c b/sourcestats.c index 522abd0c..4ea43a06 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -384,7 +384,7 @@ SST_DoNewRegression(SST_Stats inst) double est_intercept, est_slope, est_var, est_intercept_sd, est_slope_sd; int i, j, nruns; double min_distance; - double sd_weight; + double sd_weight, sd; double old_skew, old_freq, stress; int regression_ok; @@ -406,11 +406,15 @@ SST_DoNewRegression(SST_Stats inst) /* And now, work out the weight vector */ + sd = sqrt(inst->variance); + if (sd > min_distance || sd <= 0.0) + sd = min_distance; + for (i=0; in_samples; i++) { - sd_weight = 1.0 + SD_TO_DIST_RATIO * (peer_distances[i] - min_distance) / min_distance; + sd_weight = 1.0 + SD_TO_DIST_RATIO * (peer_distances[i] - min_distance) / sd; weights[i] = sd_weight * sd_weight; - } - } + } + } regression_ok = RGR_FindBestRegression(times_back + inst->runs_samples, offsets + inst->runs_samples, weights,