Regression
bestPolynomial (data: Array<Coordinate>, threshold: number, maxOrder: number): undefined|{coefficients: Array<number>, fn: (x: number): number, order: number}
Finds the most suitable polynomial regression for a given dataset.
Name | Type | Default | Description |
---|---|---|---|
data | Array<Coordinate> | ||
threshold | number | 0.85 | |
maxOrder | number | 8 |
coefficient (data: Array<Coordinate>, fn: (x: number): number): number
Finds the regression coefficient of a given data set and regression function.
Name | Type | Default | Description |
---|---|---|---|
data | Array<Coordinate> | ||
fn | (x: number): number |
exponential (data: Array<Coordinate>): Array<number>
Finds an exponential regression that best approximates a set of data. The result will be an array [a, b], where y = a * e^(bx).
Name | Type | Default | Description |
---|---|---|---|
data | Array<Coordinate> |
linear (data: Array<Coordinate>, throughOrigin: boolean): Array<number>
Finds a linear regression that best approximates a set of data. The result will be an array [c, m], where y = m * x + c.
Name | Type | Default | Description |
---|---|---|---|
data | Array<Coordinate> | ||
throughOrigin | boolean | false |
logarithmic (data: Array<Coordinate>): Array<number>
Finds a logarithmic regression that best approximates a set of data. The result will be an array [a, b], where y = a + b * log(x).
Name | Type | Default | Description |
---|---|---|---|
data | Array<Coordinate> |
polynomial (data: Array<Coordinate>, order: number): Array<number>
Finds a polynomial regression of given order
that best approximates a set of data. The result will be an array giving the coefficients of the resulting polynomial.
Name | Type | Default | Description |
---|---|---|---|
data | Array<Coordinate> | ||
order | number | 2 |