From bb40f4aff4d57da11a60c2e22bb9baf265e20ad3 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 28 Apr 2011 17:32:13 +0200 Subject: [PATCH] Modify weight calculation again 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sourcestats.c b/sourcestats.c index 9560eac..bdb07dd 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -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;