lobf
Find the line of best fit given a set of points
Example Usage
const lobf = ; const myLineOfBestFit = ; console;// Logs {// 'slope' : -2,// 'intercept' : 5.5// }
API
module.exports
is a function as follows:
function (points: [x, y][])
- calculate the line of best fit for the given points.points: [x, y][]
- an array of arrays with element0
as thex
coordinate and element1
as they
coordinate.- returns -
{ slope, intercept }
:slope: Number
- the slope of the line, or them
iny = mx + b
.intercept: Number
- the intercept of the line, or theb
iny = mx + b
.