Skip to content

linearRegressionLine

linearRegressionLine(mb): Function

Defined in: src/linear_regression_line.js:18

Given the output of linearRegression: an object with m and b values indicating slope and intercept, respectively, generate a line function that translates x values into y values.

any

object with m and b members, representing slope and intersect of desired line

Function

method that computes y-value at any given x-value on the line.

var l = linearRegressionLine(linearRegression([[0, 0], [1, 1]]));
l(0) // = 0
l(2) // = 2
linearRegressionLine({ b: 0, m: 1 })(1); // => 1
linearRegressionLine({ b: 1, m: 1 })(1); // => 2