linear-estimate
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

#linear-estimate

Linear Estimate module creates a function that is able to estimate a linear approximation of a function value based on an array of data points.

It also has functions to calculate linear estimates based on averages or sums of multiple arrays.

Type definitions

export interface Point extends Array<number> {}
export default function linearEstimateFromArray(
    array: Point[]
): (value: number) => number
export declare function linearEstimateFromAverageOfArrays(
    arrays: Point[][]
): (value: number) => number
export declare function linearEstimateFromSumOfArrays(
    arrays: Point[][]
): (value: number) => number

Examples

var f = require('linear-estimate')([[0, 0], [1, 1], [2, 4]])
f(0) //0
f(0.5) //0.5
f(1.5) //2.5
 
var f = require('linear-estimate').linearEstimateFromAverageOfArrays([
    [[0, 0], [1, 1], [2, 4]],
    [[0, 0], [1, 3], [2, 8]]
])
f(0) //0
f(0.5) //1
f(1.5) //4
 
var f = require('linear-estimate').linearEstimateFromSumOfArrays([
    [[0, 0], [1, 1], [2, 4]],
    [[0, 0], [1, 3], [2, 8]]
])
f(0) //0
f(0.5) //1
f(1.5) //4
import linearEstimateFromArray from 'linear-estimate'
const f = linearEstimateFromArray([[0, 0], [1, 1], [2, 4]])
f(0) //0
f(0.5) //0.5
f(1.5) //2.5
 
import { linearEstimateFromAverageOfArrays } from 'linear-estimate'
const f = linearEstimateFromArrays([
    [[0, 0], [1, 1], [2, 4]],
    [[0, 0], [1, 3], [2, 8]]
])
f(0) //0
f(0.5) //1
f(1.5) //4
 
import { linearEstimateFromSumOfArrays } from 'linear-estimate'
const f = linearEstimateFromArrays([
    [[0, 0], [1, 1], [2, 4]],
    [[0, 0], [1, 3], [2, 8]]
])
f(0) //0
f(0.5) //2
f(1.5) //8

Code Formatting

We use prettier for code formatting(https://prettier.io/docs/en/). If you do not have a plugin for it installed in your editor, you can format the files like so: ``

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i linear-estimate

    Weekly Downloads

    12

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    19.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • tryggingamidstodin