Class LoessInterpolator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double accuracy
      If the median residual at a certain robustness iteration is less than this amount, no more iterations are done.
      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_ACCURACY
      Default value for accuracy.
      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.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void checkAllFiniteReal​(double[] values)
      Check that all elements of an array are finite real numbers.
      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.
      private static int nextNonzero​(double[] weights, int i)
      Return the smallest index j such that j > i && (j == weights.length || weights[j] != 0).
      double[] smooth​(double[] xval, double[] yval)
      Compute a loess fit on the data at the original abscissae.
      double[] smooth​(double[] xval, double[] yval, double[] weights)
      Compute a weighted 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, double[] weights, 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], ignoring zero weights.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_BANDWIDTH

        public static final double DEFAULT_BANDWIDTH
        Default value of the bandwidth parameter.
        See Also:
        Constant Field Values
      • DEFAULT_ROBUSTNESS_ITERS

        public static final int DEFAULT_ROBUSTNESS_ITERS
        Default value of the number of robustness iterations.
        See Also:
        Constant Field Values
      • DEFAULT_ACCURACY

        public static final double DEFAULT_ACCURACY
        Default value for accuracy.
        Since:
        2.1
        See Also:
        Constant Field Values
      • serialVersionUID

        private static final long serialVersionUID
        serializable version identifier.
        See Also:
        Constant Field Values
      • bandwidth

        private final 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.

        A sensible value is usually 0.25 to 0.5.

      • robustnessIters

        private final int robustnessIters
        The number of robustness iterations parameter: this many robustness iterations are done.

        A sensible value is usually 0 (just the initial fit without any robustness iterations) to 4.

      • accuracy

        private final double accuracy
        If the median residual at a certain robustness iteration is less than this amount, no more iterations are done.
    • Method Detail

      • updateBandwidthInterval

        private static void updateBandwidthInterval​(double[] xval,
                                                    double[] weights,
                                                    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], ignoring zero weights.
        Parameters:
        xval - Arguments array.
        weights - Weights array.
        i - Index around which the new interval should be computed.
        bandwidthInterval - a two-element array {left, right} such that: (left==0 or xval[i] - xval[left-1] > xval[right] - xval[i]) and (right==xval.length-1 or xval[right+1] - xval[i] > xval[i] - xval[left]). The array will be updated.
      • nextNonzero

        private static int nextNonzero​(double[] weights,
                                       int i)
        Return the smallest index j such that j > i && (j == weights.length || weights[j] != 0).
        Parameters:
        weights - Weights array.
        i - Index from which to start search.
        Returns:
        the smallest compliant index.
      • tricube

        private static double tricube​(double x)
        Compute the tricube weight function
        Parameters:
        x - Argument.
        Returns:
        (1 - |x|3)3 for |x| < 1, 0 otherwise.
      • checkAllFiniteReal

        private static void checkAllFiniteReal​(double[] values)
        Check that all elements of an array are finite real numbers.
        Parameters:
        values - Values array.
        Throws:
        NotFiniteNumberException - if one of the values is not a finite real number.