Home > @josh-brown/vector > centralDifferenceMatrix
Builds a matrix that transforms a vector to a vector of central differences
Signature:
export declare function centralDifferenceMatrix(binCount: number): NumberMatrix;|
Parameter |
Type |
Description |
|---|---|---|
|
binCount |
number |
The size of the vector to which the output ought to be applied |
Returns:
The central difference matrix
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)_
centralDifferenceMatrix(4);
// [ 0 1/2 0 0 ]
// [ -1/2 0 1/2 0 ]
// [ 0 -1/2 0 1/2 ]
// [ 0 0 -1/2 0 ]