LinearRegression
Inherits JSON::Serializable < Reference < Object
A LinearRegression instance represents the immutable result of a least-squares linear regression.
Call LinearRegression.new(xs, ys) with your equal-sized arrays of Float64s to find a fit.
On your instance, call .at(x) to evaluate the regression line at x, or call .slope, .intercept, .pearson_r, .pearson_r_squared for metrics about the fit.
The LinearRegression may be serialized .to_json and deserialized #from_json. (The serialized state does not store the raw data points that were used to find the regression line.)
Constructors
Computes the regression given input data, where (xs[0], ys[0]) represents a single data point.
The computation happens in linear time, proportional to O(xs.size).
Raises an IndexError unless these input conditions are met: xs and ys must be the same length, and must have at least two elements.
Raises an ZeroXVarianceException if the xs values are all the same.