diff options
| author | Will Hawkins <[email protected]> | 2022-11-07 01:53:10 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2022-11-07 01:53:10 -0500 |
| commit | caa2534d422ac902f5c9dd82e7350cd0b8dfcdbb (patch) | |
| tree | 3f581e8d74308943e91fb02c50f52cb664fd2a58 /ms/ms.go | |
| parent | fd3e2aa0eb00626655ccd92a56b1d2e4b001b197 (diff) | |
[Feature] Add more functionality to MathematicalSeries
Make it easier to perform other statistical tests and functions on
mathematical series.
Diffstat (limited to 'ms/ms.go')
| -rw-r--r-- | ms/ms.go | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -77,6 +77,9 @@ func (ma *MathematicalSeries[T]) AllSequentialIncreasesLessThan(limit float64) ( return true, maximumSequentialIncrease } +/* + * N.B.: Overflow is possible -- use at your discretion! + */ func (ma *MathematicalSeries[T]) StandardDeviationLessThan(limit T) (bool, T) { // If we have not yet accumulated a complete set of intervals, @@ -112,6 +115,25 @@ func (ma *MathematicalSeries[T]) StandardDeviationLessThan(limit T) (bool, T) { // Finally, the standard deviation is the square root // of the variance. sd := T(math.Sqrt(variance)) + //sd := T(variance) return T(sd) < limit, sd } + +func (ma *MathematicalSeries[T]) IsNormallyDistributed() bool { + _, stddev := ma.StandardDeviationLessThan(0.0) + avg := float64(ma.CalculateAverage()) + + fstddev := float64(stddev) + within := float64(0) + for _, v := range ma.Values() { + if (avg-fstddev) <= float64(v) && float64(v) <= (avg+fstddev) { + within++ + } + } + return within/float64(ma.divisor.Value()) >= 0.68 +} + +func (ma *MathematicalSeries[T]) Values() []T { + return ma.elements +} |
