DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


KFilterSignalEdgeSpecial

Declaration: KFilterSignalEdgeSpecial(var Signal: TDoubleArray; ExtPolOrder: integer; FilterKernel: TDoubleArray): integer;
Kernel based filters as implemented by the function KFilterSignal exhibit the drawback of creating edge effects at the end of the filtering range (due to a decreasing number of data points when the moving kernel approaches the edge). The function KFilterSignalEdgeSpecial tries to minimize this effect by extrapolating the data at the edges using a polynomial of order ExtPolOrder (valid range: 1 to 4).

The filter is applied to the signal contained in the variable parameter Signal. The filter function is controlled by the coefficients stored in the array parameter FilterKernel. The filter coefficients for a weighted sinc lowpass/highpass filter can be calculated by means of the functions CalcSincLPKernel and CalcSincHPKernel.

The function returns the following error codes:

 0 ... everything is OK
-1 ... FilterKernel is larger than the signal range
-2 ... invalid PolyOrder (1..4 are valid)

Hint: Although this type of filter can be used with any number of filter kernel coefficients, it is strongly recommended to use only filter kernels with an odd number of coefficients in order to avoid minute shifts of the filtered signal.