Skip to content

Latest commit

 

History

History
74 lines (38 loc) · 1.35 KB

File metadata and controls

74 lines (38 loc) · 1.35 KB

Home > @josh-brown/vector > centralDifferenceMatrix

centralDifferenceMatrix() function

Builds a matrix that transforms a vector to a vector of central differences

Signature:

export declare function centralDifferenceMatrix(binCount: number): NumberMatrix;

Parameters

Parameter

Type

Description

binCount

number

The size of the vector to which the output ought to be applied

Returns:

NumberMatrix

The central difference matrix

Remarks

A backward difference matrix calculates an approximate derivative scaled by the difference when applied to a vector of function values, using a central difference _f(x - delta)/2 - f(x + delta)/2_

The central difference is equal to the average of the forward and backward differences _1/2 * (forwardDifference + backwardDifference)_

Example

centralDifferenceMatrix(4);

// [   0   1/2   0    0  ]
// [ -1/2   0   1/2   0  ]
// [   0  -1/2   0   1/2 ]
// [   0    0  -1/2   0  ]