Skip to content

Latest commit

 

History

History
92 lines (43 loc) · 1.88 KB

File metadata and controls

92 lines (43 loc) · 1.88 KB

Home > @josh-brown/vector > calculateGeneralLeastSquares

calculateGeneralLeastSquares() function

Calculates a regression model for an arbitrary function.

Signature:

export declare function calculateGeneralLeastSquares<S>(dataPoints: Vector<S>[], functionTemplate: ApproximationFunctionTemplate<S>, numberOfTerms: number): LeastSquaresApproximation<S>;

Parameters

Parameter

Type

Description

dataPoints

Vector<S>[]

The data used to construct the approximation

functionTemplate

ApproximationFunctionTemplate<S>

A higher-order function which takes a vector of coefficients and yields a new function which takes a vector of independent variables to produce a value for the dependent variable

numberOfTerms

number

The number of coefficients needed to produce the approximation function

Returns:

LeastSquaresApproximation<S>

  • the result of the linear regression

Remarks

The result is on object which has: - coefficients: a vector whose entries correspond to the coefficients which must be plugged into the function template to yield the best approximation function - approximationFunction: a function which takes a vector of the independent variable values, and returns the predicted value of the dependent variable