From d88338dcf0a53ef48eb0a8064da6e284395f5d29 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Mon, 7 Nov 2022 18:27:00 -0500 Subject: [Refactor] Change standard-deviation calculation API slightly --- ms/ms.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ms/ms.go') diff --git a/ms/ms.go b/ms/ms.go index fc0fe95..76b4b0a 100644 --- a/ms/ms.go +++ b/ms/ms.go @@ -80,7 +80,7 @@ func (ma *MathematicalSeries[T]) AllSequentialIncreasesLessThan(limit float64) ( /* * N.B.: Overflow is possible -- use at your discretion! */ -func (ma *MathematicalSeries[T]) StandardDeviationLessThan(limit T) (bool, T) { +func (ma *MathematicalSeries[T]) StandardDeviation() (bool, T) { // If we have not yet accumulated a complete set of intervals, // we are always false. @@ -117,11 +117,16 @@ func (ma *MathematicalSeries[T]) StandardDeviationLessThan(limit T) (bool, T) { sd := T(math.Sqrt(variance)) //sd := T(variance) - return T(sd) < limit, sd + return true, sd } func (ma *MathematicalSeries[T]) IsNormallyDistributed() bool { - _, stddev := ma.StandardDeviationLessThan(0.0) + valid, stddev := ma.StandardDeviation() + // If there are not enough values in our series to generate a standard + // deviation, then we cannot do this calculation either. + if !valid { + return false + } avg := float64(ma.CalculateAverage()) fstddev := float64(stddev) -- cgit v1.2.3