]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Modify weight calculation again
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 28 Apr 2011 15:32:13 +0000 (17:32 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 29 Apr 2011 11:29:56 +0000 (13:29 +0200)
Dividing the weights by variance or unweighted variance seems to have a
significant negative impact on response with normally distributed
network delays.

Divide by the difference between the mean and minimum distance instead.
It should be stable as there is no loop and the response seems to be a
good compromise between the original minimum distance weighting which
works well with normally distributed delays and the variance weighting
which works well with exponentially distributed delays.

sourcestats.c

index 9560eac413eb90e6c42c23f10a291f9e74549f8e..bdb07ddf044296a6bcfb5b49d5c0e8ccb2f90536 100644 (file)
@@ -384,7 +384,7 @@ SST_DoNewRegression(SST_Stats inst)
   int best_start, times_back_start;
   double est_intercept, est_slope, est_var, est_intercept_sd, est_slope_sd;
   int i, j, nruns;
-  double min_distance;
+  double min_distance, mean_distance;
   double sd_weight, sd;
   double old_skew, old_freq, stress;
 
@@ -395,17 +395,19 @@ SST_DoNewRegression(SST_Stats inst)
       offsets[i + inst->runs_samples] = inst->offsets[get_runsbuf_index(inst, i)];
     }
   
-    for (i = 0, min_distance = DBL_MAX; i < inst->n_samples; i++) {
+    for (i = 0, mean_distance = 0.0, min_distance = DBL_MAX; i < inst->n_samples; i++) {
       j = get_buf_index(inst, i);
       peer_distances[i] = 0.5 * inst->peer_delays[j] + inst->peer_dispersions[j];
+      mean_distance += peer_distances[i];
       if (peer_distances[i] < min_distance) {
         min_distance = peer_distances[i];
       }
     }
+    mean_distance /= inst->n_samples;
 
     /* And now, work out the weight vector */
 
-    sd = sqrt(inst->variance);
+    sd = mean_distance - min_distance;
     if (sd > min_distance || sd <= 0.0)
       sd = min_distance;