From 5bc53741be6d1faf2b9d93311fb5713b2da478c1 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 13 Dec 2016 12:50:59 +0100 Subject: [PATCH] sourcestats: add lower bound for std dev used for weighting --- sourcestats.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sourcestats.c b/sourcestats.c index 166038d..583a2a0 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -50,6 +50,9 @@ /* The minimum allowed skew */ #define MIN_SKEW 1.0e-12 +/* The minimum assumed std dev for weighting */ +#define MIN_WEIGHT_SD 1.0e-9 + /* The asymmetry of network jitter when all jitter is in one direction */ #define MAX_ASYMMETRY 0.5 @@ -507,8 +510,7 @@ SST_DoNewRegression(SST_Stats inst) /* And now, work out the weight vector */ sd = mean_distance - min_distance; - if (sd > min_distance || sd <= 0.0) - sd = min_distance; + sd = CLAMP(MIN_WEIGHT_SD, sd, min_distance); for (i=0; in_samples; i++) { sd_weight = 1.0 + SD_TO_DIST_RATIO * (peer_distances[i] - min_distance) / sd;