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


SmoothSignal

Declaration: SmoothSignal(var Signal: TDoubleArray; Mode: TSpecSmoothMode; WindowSize: integer; SmoothPar1, SmoothPar2: double): integer;
Smoothes the data in the variable Signal. The parameter Mode specifies the type of smoothing:
spsmMovAvg ... moving average
spsmWgtAvg ... weighted moving average
spsmPolynomial ... Savitzky-Golay polynomial smoothing
spsmMovMed ... moving median
spsmPenSpline ... penalized spline
spsmSincBS ... sinc band-stop (convolved with a Blackman window)
spsmSincBP ... sinc band-pass (convolved with a Blackman window)
spsmSincLP ... sinc lowpass (convolved with a Blackman window)
spsmSincHP ... sinc highpass (convolved with a Blackman window)
spsmChebychevLP ... Chebychev lowpass filter
The parameter WindowSize defines the size of the smoothing window in the case of the moving window algorithms (spsmMovAvg, spsmWgtAvg, spsmPolynomial, spsmMovMed) and must be an odd value. In the case of the penalized spline the WindowSize is irrelevant and ignored. For Chebychev filters it controls the number of poles and must be even (2..20).

The parameters SmoothPar1 and SmoothPar2 have different meanings for the various filter modes:

Mode SmoothPar1 SmoothPar2
spsmMovAvg,
spsmWgtAvg,
spsmPolynomial,
spsmMovMed
ignored ignored
spsmPenSpline controls the stiffness of the spine
valid range: 0.0 (no penalizing) to 1.0 (full penalizing)
spsmSincBS,
spsmSincBP
cut-off frequency of the lower limit of the band as a fraction of the sampling frequency
valid range: >0.0 to 0.5.
cut-off frequency of the upper limit of the band as a fraction of the sampling frequency
valid range: >0.0 to 0.5.
spsmSincLP,
spsmSincHP
cut-off frequency as a fraction of the sampling frequency
valid range: >0.0 to 0.5.
ignored
spsmChebychevLP cut-off frequency as a fraction of the sampling frequency
valid range: >0.0 to 0.5.
controls the percent ripple in the passband
valid range: 0 to 29

 

The function returns the following error codes:
 0 ... everything is OK
-3 ... invalid Mode
-4 ... WindowSize out of range
-5 ... SmoothPar1 and/or SmoothPar2 out of range
-6 ... WindowSize must be odd
-7 ... WindowSize must be less than half of the spectral range
-8 ... WindowSize must be even (Chebychev)
-9 ... SmoothPar2 out of range (Chebychev: 0..29)