Class Smooth

java.lang.Object
ubic.basecode.math.Smooth

public class Smooth extends Object
Methods for moving averages, loess
Author:
paul, ptan
  • Constructor Details

    • Smooth

      public Smooth()
  • Method Details

    • movingAverage

      public static DoubleMatrix1D movingAverage(DoubleMatrix1D m, int windowSize)
      Simple moving average that sums the points "backwards".
      Parameters:
      m -
      windowSize -
      Returns:
    • loessFit

      public static DoubleMatrix2D loessFit(DoubleMatrix2D xy)
      Parameters:
      xy -
      Returns:
      loessFit with default bandwitdh
    • loessFit

      public static DoubleMatrix2D loessFit(DoubleMatrix2D xy, double bandwidth)
      Computes a loess regression line to fit the data
      Parameters:
      xy - data to be fit
      bandwidth - the span of the smoother (from 2/n to 1 where n is the number of points in xy)
      Returns:
      loessFit (same dimensions as xy) or null if there are less than 3 data points
    • interpolate

      public static double[] interpolate(double[] x, double[] y, double[] xInterpolate)
      Linearlly interpolate values from a given data set Similar implementation of R's stats.approxfun(..., rule = 2) where values outside the interval ['min(x)', 'max(x)'] get the value at the closest data extreme. Also performs sorting based on xTrain.
      Parameters:
      x - the training set of x values
      y - the training set of y values
      xInterpolate - the set of x values to interpolate
      Returns:
      yInterpolate the interpolated set of y values