BrianHicks/elm-trend/2.1.2

NOTE: the latest version is 2.1.3

Trend.Math

Math helpers for calculating trends.

type Error
= NeedMoreValues Int
| AllZeros

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 Float -> Result Error Float

Calculate the mean (average) for some values.

mean [ 1, 2, 3, 4, 5 ]
    --> Ok 3
stddev : List Float -> Result Error Float

Calculate the standard deviation for some values.

stddev [ 1, 2, 3, 4, 5 ]
    --> Ok 1.4142135623730951
correlation : List ( Float, Float ) -> Result Error 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.