The OpenD Programming Language

simpleLinearRegression

A linear regression model with a single explanatory variable.

  1. template simpleLinearRegression(Summation summation = Summation.kbn)
  2. template simpleLinearRegression(string summation)
    template simpleLinearRegression (
    string summation
    )

Examples

import mir.math.common: approxEqual;
static immutable x = [0, 1, 2, 3];
static immutable y = [-1, 0.2, 0.9, 2.1];
auto params = x.simpleLinearRegression(y);
assert(params[0].approxEqual(-0.95)); // shift
assert(params[1].approxEqual(1)); // slope

Meta