|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.analysis.interpolation.LoessInterpolator
public class LoessInterpolator
Implements the Local Regression Algorithm (also Loess, Lowess) for interpolation of real univariate functions.
For reference, see William S. Cleveland - Robust Locally Weighted Regression and Smoothing Scatterplots This class implements both the loess method and serves as an interpolation adapter to it, allowing to build a spline on the obtained loess fit.
Field Summary | |
---|---|
private double |
bandwidth
The bandwidth parameter: when computing the loess fit at a particular point, this fraction of source points closest to the current point is taken into account for computing a least-squares regression. |
static double |
DEFAULT_BANDWIDTH
Default value of the bandwidth parameter. |
static int |
DEFAULT_ROBUSTNESS_ITERS
Default value of the number of robustness iterations. |
private int |
robustnessIters
The number of robustness iterations parameter: this many robustness iterations are done. |
private static long |
serialVersionUID
serializable version identifier. |
Constructor Summary | |
---|---|
LoessInterpolator()
Constructs a new LoessInterpolator
with a bandwidth of DEFAULT_BANDWIDTH and
DEFAULT_ROBUSTNESS_ITERS robustness iterations. |
|
LoessInterpolator(double bandwidth,
int robustnessIters)
Constructs a new LoessInterpolator
with given bandwidth and number of robustness iterations. |
Method Summary | |
---|---|
private static void |
checkAllFiniteReal(double[] values,
boolean isAbscissae)
Check that all elements of an array are finite real numbers. |
private static void |
checkStrictlyIncreasing(double[] xval)
Check that elements of the abscissae array are in a strictly increasing order. |
PolynomialSplineFunction |
interpolate(double[] xval,
double[] yval)
Compute an interpolating function by performing a loess fit on the data at the original abscissae and then building a cubic spline with a SplineInterpolator
on the resulting fit. |
double[] |
smooth(double[] xval,
double[] yval)
Compute a loess fit on the data at the original abscissae. |
private static double |
tricube(double x)
Compute the tricube weight function |
private static void |
updateBandwidthInterval(double[] xval,
int i,
int[] bandwidthInterval)
Given an index interval into xval that embraces a certain number of points closest to xval[i-1], update the interval so that it embraces the same number of points closest to xval[i] |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
public static final double DEFAULT_BANDWIDTH
public static final int DEFAULT_ROBUSTNESS_ITERS
private final double bandwidth
private final int robustnessIters
Constructor Detail |
---|
public LoessInterpolator()
LoessInterpolator
with a bandwidth of DEFAULT_BANDWIDTH
and
DEFAULT_ROBUSTNESS_ITERS
robustness iterations.
See LoessInterpolator(double, int)
for an explanation of
the parameters.
public LoessInterpolator(double bandwidth, int robustnessIters) throws MathException
LoessInterpolator
with given bandwidth and number of robustness iterations.
bandwidth
- when computing the loess fit at
a particular point, this fraction of source points closest
to the current point is taken into account for computing
a least-squares regression.
A sensible value is usually 0.25 to 0.5, the default value is
DEFAULT_BANDWIDTH
.robustnessIters
- This many robustness iterations are done.
A sensible value is usually 0 (just the initial fit without any
robustness iterations) to 4, the default value is
DEFAULT_ROBUSTNESS_ITERS
.
MathException
- if bandwidth does not lie in the interval [0,1]
or if robustnessIters is negative.Method Detail |
---|
public final PolynomialSplineFunction interpolate(double[] xval, double[] yval) throws MathException
SplineInterpolator
on the resulting fit.
interpolate
in interface UnivariateRealInterpolator
xval
- the arguments for the interpolation pointsyval
- the values for the interpolation points
MathException
- if some of the following conditions are false:
public final double[] smooth(double[] xval, double[] yval) throws MathException
xval
- the arguments for the interpolation pointsyval
- the values for the interpolation points
MathException
- if some of the following conditions are false:
private static void updateBandwidthInterval(double[] xval, int i, int[] bandwidthInterval)
xval
- arguments arrayi
- the index around which the new interval should be computedbandwidthInterval
- a two-element array {left, right} such that:
(left==0 or xval[i] - xval[left-1] > xval[right] - xval[i])
and also
(right==xval.length-1 or xval[right+1] - xval[i] > xval[i] - xval[left]).
The array will be updated.private static double tricube(double x)
x
- the argument
private static void checkAllFiniteReal(double[] values, boolean isAbscissae) throws MathException
values
- the values arrayisAbscissae
- if true, elements are abscissae otherwise they are ordinatae
MathException
- if one of the values is not
a finite real numberprivate static void checkStrictlyIncreasing(double[] xval) throws MathException
xval
- the abscissae array
MathException
- if the abscissae array
is not in a strictly increasing order
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |