public class Interpolator extends Object
Modifier and Type | Class and Description |
---|---|
class |
Interpolator.Cubic
represents a cubic polynomial.
|
Constructor and Description |
---|
Interpolator(double[] aX,
double[] aY)
Initialize interpolator
|
Interpolator(H1D h1)
Initialize interpolator for a histogram.
|
Interpolator(P1D p1d)
Initialize interpolator for P1D array.
|
Modifier and Type | Method and Description |
---|---|
double |
getMaxValue()
Get min value of data in X
|
double |
getMinValue()
Get maximum value of data in X
|
umontreal.iro.lecuyer.functionfit.SmoothingCubicSpline |
interpolateCubicSpline(double rho,
int option)
Calculate a spline with nodes at (x, y), with weights w and smoothing
factor rho.
|
org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction |
interpolateLoess(double bandwidth,
int robustnessIters,
double accuracy,
int option)
Performs a Local Regression Algorithm (also Loess, Lowess) for
interpolation of data points.
|
Interpolator.Cubic[] |
interpolateNatuarlCubicSpline()
Natural cubic splines interpolation.
|
void |
setRange(double xMin,
double xMax)
Redefine smooth interval for input data.
|
P1D |
smoothAverage(boolean isWeighted,
int k)
Smooth data by averaging over a moving window.
|
P1D |
smoothCubicSpline()
Perform a cubic interpolatory spline.
|
P1D |
smoothGauss(double standardDeviation)
Computes a Gaussian smoothed version of data.
|
P1D |
smoothLoess(double bandwidth,
int robustnessIters,
double accuracy)
Performs a Local Regression Algorithm (also Loess, Lowess) for
interpolation of data points.
|
P1D |
smoothLoess(double bandwidth,
int robustnessIters,
double accuracy,
int option)
Performs a Local Regression Algorithm (also Loess, Lowess) for
interpolation of data points.
|
P1D |
smoothSpline()
Computes a natural (also known as "free", "unclamped") cubic spline
interpolation for the data set.
|
public Interpolator(double[] aX, double[] aY)
aX
- is the array of x dataaY
- is the array of y datapublic Interpolator(P1D p1d)
p1d
- p1d values x-y and y-error is used to estimate weight
(1/error*error)public Interpolator(H1D h1)
h1
- input for interpolation. X - mean value in a bin, y is a
height and weight is 1/(error*error)public void setRange(double xMin, double xMax)
xMin
- minimal value for XxMax
- maximal value for Ypublic org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction interpolateLoess(double bandwidth, int robustnessIters, double accuracy, int option)
Compute an interpolating function by performing a loess fit on the data at the original abscissa and then building a cubic spline. Weights of the input data are not taken into account.
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.robustnessIters
- How many robustness iterations are done. A sensible value is
usually 0 (just the initial fit without any robustness
iterations) to 4.public P1D smoothLoess(double bandwidth, int robustnessIters, double accuracy, int option)
Compute an interpolating function by performing a loess fit on the data at the original abscissa and then building a cubic spline.
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.robustnessIters
- How many robustness iterations are done. A sensible value is
usually 0 (just the initial fit without any robustness
iterations) to 4.accuracy
- If the median residual at a certain robustness iteration is
less than this amount, no more iterations are done. A typical
value is 2option
- treatment of errors on data points: public umontreal.iro.lecuyer.functionfit.SmoothingCubicSpline interpolateCubicSpline(double rho, int option)
For x < x0 and x > xn-1, the spline is not precisely defined, but this class performs extrapolation by using S0 and Sn linear polynomials. The algorithm which calculates the smoothing spline is a generalization of the algorithm for an interpolating spline. Si is linked to Si+1 at xi+1 and keeps continuity properties for first and second derivatives at this point, therefore Si(xi+1) = Si+1(xi+1), S'i(xi+1) = S'i+1(xi+1) and S''i(xi+1) = S''i+1(xi+1).
The spline is computed with a smoothing parameter ρ∈[0, 1] which represents its accuracy with respect to the initial (xi, yi) nodes. The smoothing spline minimizes
In fact, by setting ρ = 1, we obtain the interpolating spline; and we obtain a linear function by setting ρ = 0. The weights wi > 0, which default to 1, can be used to change the contribution of each point in the error term. A large value wi will give a large weight to the ith point, so the spline will pass closer to it.
rho
- smoothing factor rho.option
- treatment of errors on data points: public P1D smoothLoess(double bandwidth, int robustnessIters, double accuracy)
Compute an interpolating function by performing a loess fit on the data at the original abscissa and then building a cubic spline. If errors on Y are given (from a histogram or P1D), assume the weighths equal 1/(errorY*errorY).
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.robustnessIters
- How many robustness iterations are done. A sensible value is
usually 0 (just the initial fit without any robustness
iterations) to 4.accuracy
- If the median residual at a certain robustness iteration is
less than this amount, no more iterations are done.option
- treatment of errors on data points: public P1D smoothSpline()
The value of the PolynomialSplineFunction at each of the input x values equals the corresponding y value. Adjacent polynomials are equal through two derivatives at the knot points (i.e., adjacent polynomials "match up" at the knot points, as do their first and second derivatives).
The cubic spline interpolation algorithm implemented is as described in R.L. Burden, J.D. Faires, Numerical Analysis, 4th Ed., 1989, PWS-Kent, ISBN 0-53491-585-X, pp 126-131.
public P1D smoothCubicSpline()
public P1D smoothGauss(double standardDeviation)
The data are smoothed by discrete convolution with a kernel approximating a Gaussian impulse response with the specified standard deviation.
standardDeviation
- The standard deviation of the Gaussian smoothing kernel which
must be non-negative or an
IllegalArgumentException
will be thrown. If zero,
the P1D object will be returned with no smoothing applied.public P1D smoothAverage(boolean isWeighted, int k)
It is smoothed by averaging over a moving window of a size specified by the method parameter: if the value of the parameter is k then the width of the window is 2*k + 1. If the window runs off the end of the P1D only those values which intersect the histogram are taken into consideration. The smoothing may optionally be weighted to favor the central value using a "triangular" weighting. For example, for a value of k equal to 2 the central bin would have weight 1/3, the adjacent bins 2/9, and the next adjacent bins 1/9. Errors are kept the same as before.
isWeighted
- Whether values Y will be weighted using a triangular weighting
scheme favoring bins near the central bin.k
- The smoothing parameter which must be non-negative. If zero,
the histogram object will be returned with no smoothing
applied.public double getMaxValue()
public double getMinValue()
public Interpolator.Cubic[] interpolateNatuarlCubicSpline()
SCaVis 1.0 ©