deno.land / x / simplestatistic@v7.7.1 / src / linear_regression_line.js

linear_regression_line.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/** * 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. * * @param {Object} mb object with `m` and `b` members, representing * slope and intersect of desired line * @returns {Function} method that computes y-value at any given * x-value on the line. * @example * 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 */function linearRegressionLine(mb /*: { b: number, m: number }*/) { // Return a function that computes a `y` value for each // x value it is given, based on the values of `b` and `a` // that we just computed. return function (x) { return mb.b + mb.m * x; };}
export default linearRegressionLine;
simplestatistic

Version Info

Tagged at
2 years ago