jxxcarlson/elm-stat/2.0.2

NOTE: the latest version is 6.0.3

Stat

The aim of this library is to compute statistics for 2D data.

type alias Data =
List Point

The fundamental data structure: a list of points.

type alias Point =
{ x : Float
, y : Float
}

A point in the Cartesian plane given by x and y coordinates

type alias Statistics =
{ m : Float
, b : Float
, n : Int
, r2 : Float
, xMin : Float
, xMax : Float
, xMean : Float
, yMean : Float
, xStdev : Float
, yStdev : Float
, leftDataPoint : Point
, rightDataPoint : Point
, leftRegressionPoint : Point
, rightRegressionPoint : Point
}

A Statistics value holds information like the mean and standard deviation of the x and y values of Data value (list of points), as well as the coefficients m and b of the regression line, the R^2 value, etc. Compute using statistics data.

mean : (data -> Float) -> List data -> Maybe Float

Compute the mean of a column in a list of data, e.g.,

```mean .x data```

which computes the mean of the x-values.

mode : List comparable -> Maybe ( comparable, Int )

Compute the mode of the data:

data = [1, 5, 2, 2, 2, 2, 5, 3, 1][1,5,2,2,2,2,5,3,1]

mode data Just (2,4) : Maybe ( number, Int ) data = ["red", "green", "red", "blue", "blue", "red"]["red","green","red","blue","blue","red"]

mode data Just ("red",3) : Maybe ( String, Int )

filter : Filter -> Data -> Data

Apply filters to the data, This is set up as a pipeline so that other filters can be added later. We may have to go with different architectue if we have may filters -- best to avoid too many repeated list traversals.

maximum : (data -> Float) -> List data -> Maybe Float

Compute the maximum of a column in a list of data, e.g.,

```maximum .x data```

which computes the maximum of the x-values.

minimum : (data -> Float) -> List data -> Maybe Float

Compute the minimum of a column in a list of data, e.g.,

```minimum .x data```

which computes the minimum of the x-values.

statistics : Data -> Maybe Statistics

Compute the statistics of a Data value.

stdev : (data -> Float) -> List data -> Maybe Float

Compute the standard deviation of a column in a list of data, e.g.,

```stdev .x data```

which computes the standard deviation of the x-values.