##
peakml.math.filter

Class SavitzkyGolayFilter

java.lang.Object
**peakml.math.filter.SavitzkyGolayFilter**

**All Implemented Interfaces:** - Filter

public class **SavitzkyGolayFilter**

- extends java.lang.Object
- implements Filter

Implementation of the Savitzky-Golay filter taken from Numerical Recipes in C
(chapter 14.8, page 650). This filter smoothes the incoming signal by replacing
each value in the series with the value obtained from a polynomial fit on the
window around the value with size 2n+1.

The Points-enum indicates the possible window-sizes. This has been restricted
due to the fact that the algorithm utilizes pre-calculated coefficients. A
smaller window-size keeps the signal intact, but removes less noise.

**Method Summary** |

` double[]` |
**filter**(double[] xvals,
double[] yvals)
With this method actual filtering is performed. |

**Methods inherited from class java.lang.Object** |

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait` |

###
SavitzkyGolayFilter

public **SavitzkyGolayFilter**(SavitzkyGolayFilter.Points points)

- Standard constructor, which accepts the number of data points to use in for
the smoothing filter.

**Parameters:**`points`

- The number of data points to use.

###
filter

public double[] **filter**(double[] xvals,
double[] yvals)
throws java.lang.IllegalArgumentException

**Description copied from interface: **`Filter`

- With this method actual filtering is performed. The xvals and yvals arrays
should be of equal length, otherwise an IllegalArgumentException is thrown.
The return value is the new yvals array, with smoothed out values. The
returned array is of the same size as the x and y value arrays.

**Specified by:**`filter`

in interface `Filter`

**Parameters:**`xvals`

- The x-values of the signal.`yvals`

- The y-values of the signal.
**Returns:**- The resulting smoothed version of the y-values.
**Throws:**
`java.lang.IllegalArgumentException`