Home Reference Source Repository

Function

Static Public Summary
public

avgPoints(pointArr: array, pointSums: array): array

Returns the average of x values and y values in a 2 dimensional array

public

balanceMagnitude(result: number, variable: number, weight: number, error: number): number

Returns a value that, when multiplied with variable, weight, and error arguments, will result in a value of the same magnitude as the result argument.

public

balanceMagnitudeArray(inputArr: array[number], weightArr: array[number], error: number): array[number]

Returns an array of values that, when multiplied with variable, weight, and error arguments, will result in a value of the same magnitude as the result argument.

public

cummulativeAvgPoints(input: number | array[numbers], cummulativeAvg: number, cummulativeN: number): number

Returns average value of the given input and a previously calculated average

public

cummulativeRangePoints(input: number | array[numbers], cummulativeRange: array[numbers]): array

Returns range of the given inputs and a previously calculated range

public

evalError(inputArr: array[numbers], weightArr: array[numbers]): number

Returns an error value from inputs and weights

public

evalGuess(input: array[numbers], weightArr: array[numbers]): number

Returns an expected result using supplied inputs and weights

public

gradientStep(weightArr: array[numbers], input: array[numbers], error: number, learningRateArr: array[number]): array

Returns a new set of weights

public

interceptOLS(lineObj: object, avg: array): number

Returns the intercept for a line of an Ordinary Least Squares regression

public

meanSquaredErrors(pointArr: array, lineObj: object): number

Returns the MSE of a 2D coordinate array

public

ols_regression(pointArr: *): object

Returns an object representing the ordinary least squares line

public

Returns the position x in a sigmoid curve

public

Returns the position x in a derivative sigmoid curve

public

sumPoints(pointArr: array): array

Returns the sum of x values and y values in a 2 dimensional array

public

sumSquaredErrors(pointArr: array, lineObj: object): number

Returns the SSE (sum of squared errors) for a 2D coordinate array

public

sumSquaredResiduals(pointArr: array, avg: array): number

Returns the SSR (sum of squared residuals) for a 2D coordinate array

Static Public

public avgPoints(pointArr: array, pointSums: array): array source

Returns the average of x values and y values in a 2 dimensional array

Params:

NameTypeAttributeDescription
pointArr array

An array containing all coordinate points

pointSums array

An array containing the computed sum of all x values and all y values

Return:

array

An array containing the average x value and y value of the pointArr

public balanceMagnitude(result: number, variable: number, weight: number, error: number): number source

Returns a value that, when multiplied with variable, weight, and error arguments, will result in a value of the same magnitude as the result argument.

Params:

NameTypeAttributeDescription
result number

a y value, or the variable that the line is fitted to predict.

variable number

an x value.

weight number

the weight associated with the x value.

error number

the error associated with the current gradient step.

Return:

number

An integer representing the power of 10 value that would balance result with the product of all other arguments

public balanceMagnitudeArray(inputArr: array[number], weightArr: array[number], error: number): array[number] source

Returns an array of values that, when multiplied with variable, weight, and error arguments, will result in a value of the same magnitude as the result argument.

Params:

NameTypeAttributeDescription
inputArr array[number]

an array of y and x values representing a potential input.

weightArr array[number]

an array of weights.

error number

the error associated with the current gradient step.

Return:

array[number]

An array representing the power of 10 values that would balance results with the product of all other arguments

public cummulativeAvgPoints(input: number | array[numbers], cummulativeAvg: number, cummulativeN: number): number source

Returns average value of the given input and a previously calculated average

Params:

NameTypeAttributeDescription
input number | array[numbers]

A number or array representing the values to be averaged

cummulativeAvg number

A value representing the current average of values seen up until this point

cummulativeN number

A value representing the number of values seen up until this point

Return:

number

A weighted average

public cummulativeRangePoints(input: number | array[numbers], cummulativeRange: array[numbers]): array source

Returns range of the given inputs and a previously calculated range

Params:

NameTypeAttributeDescription
input number | array[numbers]

A number or array representing the values to be evaluated

cummulativeRange array[numbers]

A array representing the current range of values seen up until this point

Return:

array

A range of the given inputs

public evalError(inputArr: array[numbers], weightArr: array[numbers]): number source

Returns an error value from inputs and weights

Params:

NameTypeAttributeDescription
inputArr array[numbers]

An array representing the values to be evaluated, with the y value in the [0] position

weightArr array[numbers]

An array representing the weights to be used with the values, with b0 in the [0] position

Return:

number

Sum of errors using the weightArr

public evalGuess(input: array[numbers], weightArr: array[numbers]): number source

Returns an expected result using supplied inputs and weights

Params:

NameTypeAttributeDescription
input array[numbers]

An array representing x and y values

weightArr array[numbers]

An array representing weights used to estimate a y value

Return:

number

An expected y value

public gradientStep(weightArr: array[numbers], input: array[numbers], error: number, learningRateArr: array[number]): array source

Returns a new set of weights

Params:

NameTypeAttributeDescription
weightArr array[numbers]

An array of numbers representing estimated weights, with b0 in the [0] position

input array[numbers]

An array of numbers representing the original inputs in some way, with y in the [0] position

error number

A number representing an error value pointing in the direction of the next gradient step

learningRateArr array[number]

An array of numbers representing the magnitudes of changes in the weights

Return:

array

A new set of weights

public interceptOLS(lineObj: object, avg: array): number source

Returns the intercept for a line of an Ordinary Least Squares regression

Params:

NameTypeAttributeDescription
lineObj object

An object containing at least a b1 property with the value of the expected slope

avg array

An array containing a y value at [1] and an x value at position [0]

Return:

number

An expected intercept value

public meanSquaredErrors(pointArr: array, lineObj: object): number source

Returns the MSE of a 2D coordinate array

Params:

NameTypeAttributeDescription
pointArr array

An array containing all coordinate points

lineObj object

An object containing the b1 and b0 weights for an OLS regression

Return:

number

A number representing the MSE of a 2D coordinate array

public ols_regression(pointArr: *): object source

Returns an object representing the ordinary least squares line

Params:

NameTypeAttributeDescription
pointArr *

Return:

object

An object representing a line

public sigmoidCurve(x: number): number source

Returns the position x in a sigmoid curve

Params:

NameTypeAttributeDescription
x number

An x value along the sigmoid curve

Return:

number

y - The y value corresponding to the provided x value

public sigmoidDerivative(x: number): number source

Returns the position x in a derivative sigmoid curve

Params:

NameTypeAttributeDescription
x number

An x value along the derivative sigmoid curve

Return:

number

y - The y value corresponding to the provided x value

public sumPoints(pointArr: array): array source

Returns the sum of x values and y values in a 2 dimensional array

Params:

NameTypeAttributeDescription
pointArr array

An array containing all coordinate points

Return:

array

An array containing the sums of x values and y values of the pointArr

public sumSquaredErrors(pointArr: array, lineObj: object): number source

Returns the SSE (sum of squared errors) for a 2D coordinate array

Params:

NameTypeAttributeDescription
pointArr array

An array containing a set of coordinate points

lineObj object

An object containing the b1 and b0 weights for an OLS regression

Return:

number

A number representing the SSE of the points in pointArr given the line specified by lineObj

public sumSquaredResiduals(pointArr: array, avg: array): number source

Returns the SSR (sum of squared residuals) for a 2D coordinate array

Params:

NameTypeAttributeDescription
pointArr array

An array containing a set of coordinate points

avg array

An array containing the average of all y values and all x values

Return:

number

A number representing the SSR of the points in pointArr given the average value