Math helpers for calculating trends.
Indicate that something has gone wrong in the caculation of a trend line. Specifically:
NeedMoreValues
: there was not enough data to calculate a
value. The attached Int
is the minimum required.AllZeros
: this likely means you've tried to plot a point
through a bunch of zeroes, or a values that are very very close to
zero. If that's not the case, please open an issue.mean : List Basics.Float -> Result Error Basics.Float
Calculate the mean (average) for some values.
mean [ 1, 2, 3, 4, 5 ]
--> Ok 3
stddev : List Basics.Float -> Result Error Basics.Float
Calculate the standard deviation for some values.
stddev [ 1, 2, 3, 4, 5 ]
--> Ok 1.4142135623730951
correlation : List ( Basics.Float, Basics.Float ) -> Result Error Basics.Float
Get the correlation coefficient for some values. The returned value will be between 0 (no correlation) and 1 (perfect correlation.)
correlation [ (1, 1), (2, 2), (3, 3), (4, 4) ]
--> Ok 1
Minimum required values: 2
Under the covers, this is a Pearson correlation coefficient.