peakml.math.filter
Class LoessFilter
java.lang.Object
peakml.math.filter.LoessFilter
- All Implemented Interfaces:
- Filter
public class LoessFilter
- extends java.lang.Object
- implements Filter
Implementation of a LOESS filter (also known as local regression) for smoothing
signals. The method is also called Locally Weighted Polynomial Regression, because
at each point in the dataset a low-degree polynomial is fit to a subset of the
given window-size. The polynomial function is fitted to the data using weighted
least squaresgiving more weight to points near the point whose response is being
estimated and less weight to points further away. The value of the regression function
for the point is then obtained by evaluating the local polynomial using the explanatory
variable values for that data point. The LOESS fit is complete after regression
function values have been computed for each of the n data points.
The disadvantage of the LOESS filter is that it requires fairly large, densely sampled
datasets in order to produce good models. Furthermore, the method is known to be
fairly computational intensive.
http://en.wikipedia.org/wiki/Local_regression
Constructor Summary |
LoessFilter(double windowsize)
Standard constructor, which accepts the window-size to use for the
smoothing filter. |
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 |
LoessFilter
public LoessFilter(double windowsize)
- Standard constructor, which accepts the window-size to use for the
smoothing filter.
- Parameters:
windowsize
- The windowsize expressed in percentage of the number of data-points.
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