Skip to content

bdsomer/lobf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lobf

Find the line of best fit given a set of points

lobf on NPM

Build Status lobf's Total Downloads on NPM lobf's Version on NPM bitHound Overall Score bitHound Code Dependencies Dev Dependencies Known Vulnerabilities lobf's License lobf's Stars on GitHub

Example Usage

const lobf = require('lobf');

const myLineOfBestFit = lobf([
	// [x, y]
	[1.5, 3],
	[1.5, 2],
	[2, 1.5]
]);

console.log(myLineOfBestFit);
// 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 element 0 as the x coordinate and element 1 as the y coordinate.
    • returns - { slope, intercept }:
      • slope: Number - the slope of the line, or the m in y = mx + b.
      • intercept: Number - the intercept of the line, or the b in y = mx + b.

Releases

No releases published

Packages

No packages published