Calculate trend lines given 2-dimensonal data.
A line plotted through points. Get one by passing your data to
linear.
Make predictions using this and predictY and measure
accuracy with goodnessOfFit.
How good is the fit that linear generated? We can
give you a confidence between 0 and 1 representing a percent
confidence. Practically, we'll usually return a value between almost 0
and almost 1.
values : List (Float, Float)
values =
[ (1, 1), (2, 2), (3, 3), (4, 4) ]
linear values
|> Result.andThen (\fit -> goodnessOfFit fit values)
--> Ok 1Statistically speaking, this is the R-squared value of the linear regression.
Indicate that something has gone wrong in the caculation of a trend line. Specifically:
NotEnoughData: there was not enough data to calculate a trend. The
number attached is the minimum number of points needed to
calculate.ResultWasNaN: this likely means you've tried to plot a point
through a bunch of zeroes, or a bunch of values that are very very
close to zero. If that's not the case, please open an issue.
Plot a line through a series of points
(x, y).Use this in situations where the relationship between
xandyis linear and has as few outliers as possible. A relationship is linear if it can be described accurately asy = x * slope + intercept. The easiest way to determine this is to look at a plot of your values. If they look roughly like a line, we're in business. But if your plot shows a curve or a random point cloud then don't trust the results of this function applied to them.Examples of data which fit these criteria:
Statistically speaking, this is a least-squares regression.