From 08195d7e41785f93463fd9a5344dbfda9ae3b1a4 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 27 Mar 2015 10:20:55 +0100 Subject: [PATCH] sourcestats: fix updating of slope on slew with large residual freq --- sourcestats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sourcestats.c b/sourcestats.c index 7e97085..52e5034 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -634,14 +634,14 @@ SST_SlewSamples(SST_Stats inst, struct timeval *when, double dfreq, double doffs inst->offsets[i] += delta_time; } - /* Do a half-baked update to the regression estimates */ + /* Update the regression estimates */ prev = inst->offset_time; prev_offset = inst->estimated_offset; prev_freq = inst->estimated_frequency; UTI_AdjustTimeval(&(inst->offset_time), when, &(inst->offset_time), &delta_time, dfreq, doffset); inst->estimated_offset += delta_time; - inst->estimated_frequency -= dfreq; + inst->estimated_frequency = (inst->estimated_frequency - dfreq) / (1.0 - dfreq); DEBUG_LOG(LOGF_SourceStats, "n=%d m=%d old_off_time=%s new=%s old_off=%f new_off=%f old_freq=%.3f new_freq=%.3f", inst->n_samples, inst->runs_samples,