Contains functions to create a linear forecast, i. e. a simple trend line.
regression : List ( Basics.Float, Basics.Float ) -> Basics.Float -> Basics.Float
Expects a list of Float-tuples, where the first element is the x- and the second element is the y-coordinate of a point. It returns a linear function, that gets a Float and emits new values.
vals = [(0, 0), (1, 0.5), (2, 1), (3, 1.5)]
regressionFunction = regression vals
regressionFunction 4 == 2
forecast : Basics.Int -> List ( Basics.Float, Basics.Float ) -> List ( Basics.Float, Basics.Float )
Creates a list of tuples with forecasted values. The first parameter indicates how many values.
Please note that this function expects to get a sorted list of points. It will create a range based on the last point.
vals = [(0, 0), (0.5, 0.25), (1, 0.5), (3, 1.5)]
forecast 3 vals == [(4, 2), (5, 2.5), (6, 3)]