1.0.1 • Published 5 years ago

linfit v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Linear Curve Fit with Standard Error

A simple least-squares fit function which calculates linear coefficients with their standard errors and correlation coefficient (r2).

Given an array of x-y pairs:

var data = [
    {x:0, y:0.1},
    {x:1, y:0.9},
    {x:2, y:2.2},
    {x:3, y:3.2},
    {x:4, y:3.9},
];

when linfit is evaluated

var fit = require('linfit');
. . .
var result = fit(data);

it will return

result = {
   "A": 0.0800000000000003,
   "B": 0.9899999999999999,
   "dA": 0.1425949975747162,
   "dB": 0.0336099632494537,
   "rr": 0.9967320261437909
}

where

ResultDescription
Ay-intercept
dAstandard error of the y-intercept
Bslope
dBstandard error of the slope
rrcorrelation coefficient

and

y = (A ± dA) + (B ± dB)x

1.0.1

5 years ago

1.0.0

5 years ago

0.9.1

8 years ago

0.9.0

8 years ago