vec_math
Class SavitzkyGolaySmoothing

java.lang.Object
  extended by vec_math.LinearSmoothing
      extended by vec_math.SavitzkyGolaySmoothing

public class SavitzkyGolaySmoothing
extends LinearSmoothing

This class provides a Saviztky-Golay Digital Smoothing filter. It is a sort of low-bandpass digital filter that preserves higher moments. For each point fi, a least-square fit of a polynomial of given degree within all points in the smoothing window is generated. The smoothed value, gi is the value of the smoothing polynomial at position i. Typical degrees of the smoothing polynomial are two or four. The smoothing window must not be symmetric around i, in fact it can even extend to only one side of i.

Literature:
Numerical Recipes in C, p. 650ff


Nested Class Summary
static class SavitzkyGolaySmoothing.Coeff
          We test the calculation of the coefficients.
static class SavitzkyGolaySmoothing.Corot
          Reads the specified column of a data file and does a Savitzky-Golay filtering.
static class SavitzkyGolaySmoothing.FM
          Test purpose.
 
Nested classes/interfaces inherited from class vec_math.LinearSmoothing
LinearSmoothing.File
 
Field Summary
protected  int degree
           
protected  int derivative
           
private static double[] M2L2R2
           
private static double[] M2L3R1
           
private static double[] M2L4R0
           
private static double[] M2L5R5
           
private static double[] M4L4R4
           
private static double[] M4L5R5
           
private static double[] M4L6R0D1
           
 
Fields inherited from class vec_math.LinearSmoothing
cn, dn, FIR, IIR, nj, nk, type
 
Constructor Summary
SavitzkyGolaySmoothing()
          Defaults to M2L4R0.
SavitzkyGolaySmoothing(InputStream coef)
          This is the version of Savitzky-Golay smoothing that expects pre-calculated coefficients.
SavitzkyGolaySmoothing(int nl, int nr)
          Defaults to a polynomial degree of 2.
SavitzkyGolaySmoothing(int deg, int nl, int nr, int der)
           
 
Method Summary
protected  void calcInputCoeff(InputStream instream)
          This method is called only at construct.
private static double[] calculateCoeff(int nl, int nr, int der, int deg)
           
 int getDegree()
          A method to return the degree of the smoothing polynom.
 int getDerivative()
          A method to return the derivative of the smoothing polynom.
protected  void setType()
          Sets the type of this filter.
 
Methods inherited from class vec_math.LinearSmoothing
getM, getN, getNj, getNk, getType, isValid, movingAverage, smoothAll, smoothAll, smoothAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

M2L2R2

private static final double[] M2L2R2

M2L3R1

private static final double[] M2L3R1

M2L4R0

private static final double[] M2L4R0

M2L5R5

private static final double[] M2L5R5

M4L6R0D1

private static final double[] M4L6R0D1

M4L4R4

private static final double[] M4L4R4

M4L5R5

private static final double[] M4L5R5

degree

protected int degree

derivative

protected int derivative
Constructor Detail

SavitzkyGolaySmoothing

public SavitzkyGolaySmoothing()
Defaults to M2L4R0.


SavitzkyGolaySmoothing

public SavitzkyGolaySmoothing(int nl,
                              int nr)
Defaults to a polynomial degree of 2.


SavitzkyGolaySmoothing

public SavitzkyGolaySmoothing(int deg,
                              int nl,
                              int nr,
                              int der)

SavitzkyGolaySmoothing

public SavitzkyGolaySmoothing(InputStream coef)
This is the version of Savitzky-Golay smoothing that expects pre-calculated coefficients. They must be stored in the readable ASCII-file coef and must obay the following format:

One can generate a coefficient file that follows this format by using the C-program savgol.

Parameters:
coef - The ascii-file holding the smoothing parameters.
Method Detail

calculateCoeff

private static double[] calculateCoeff(int nl,
                                       int nr,
                                       int der,
                                       int deg)

setType

protected void setType()
Description copied from class: LinearSmoothing
Sets the type of this filter. Is generic to each filter, so no arguments can be passed to this method. The method should be protected, because we do not want anybody to manipulate it from outside.

Specified by:
setType in class LinearSmoothing

calcInputCoeff

protected void calcInputCoeff(InputStream instream)
This method is called only at construct. The coefficients are not calculated, but read in from an ascii-file. If the file does not follow the desired format, an IllegalArgumentException is thrown Refer to #SavitzkyGolaySmoothing(File) for valid file formats.


getDegree

public int getDegree()
A method to return the degree of the smoothing polynom. The smoothing polynom is specific to a Savitzky-Golay smoothing, therefore it is not present in the base class.


getDerivative

public int getDerivative()
A method to return the derivative of the smoothing polynom.

Returns:
The nth derivative this smoothing was designed for