Example usage for org.apache.commons.math.analysis.interpolation LoessInterpolator interpolate

List of usage examples for org.apache.commons.math.analysis.interpolation LoessInterpolator interpolate

Introduction

In this page you can find the example usage for org.apache.commons.math.analysis.interpolation LoessInterpolator interpolate.

Prototype

public final PolynomialSplineFunction interpolate(final double[] xval, final double[] yval)
        throws MathException 

Source Link

Document

Compute an interpolating function by performing a loess fit on the data at the original abscissae and then building a cubic spline with a org.apache.commons.math.analysis.interpolation.SplineInterpolator on the resulting fit.

Usage

From source file:guineu.modules.filter.Alignment.SerumHuNormalization.SerumHuNormalizationTask.java

private PolynomialSplineFunction createCurve() {
    try {//from w  ww .j a  va2  s  .  com
        // if there are more than 2 points in the model
        LoessInterpolator loess = null;
        if (this.loessBandwidth == 0 && this.iterations == 0) {
            loess = new LoessInterpolator();
        } else {
            loess = new LoessInterpolator(this.loessBandwidth, this.iterations);
        }
        double[] newy = loess.smooth(xval, yval);
        PolynomialSplineFunction function = loess.interpolate(xval, newy);
        return function;

    } catch (MathException ex) {
        Logger.getLogger(SerumHuNormalizationTask.class.getName()).log(Level.SEVERE, null, ex);

        SplineInterpolator loess = new SplineInterpolator();
        PolynomialSplineFunction function = loess.interpolate(xval, yval);
        return function;

    }
}