Package ubic.basecode.math
Class Smooth
- java.lang.Object
-
- ubic.basecode.math.Smooth
-
public class Smooth extends Object
Methods for moving averages, loess- Author:
- paul, ptan
-
-
Constructor Summary
Constructors Constructor Description Smooth()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static cern.colt.matrix.DoubleMatrix2D
loessFit(cern.colt.matrix.DoubleMatrix2D xy)
static cern.colt.matrix.DoubleMatrix2D
loessFit(cern.colt.matrix.DoubleMatrix2D xy, double bandwidth)
Computes a loess regression line to fit the datastatic cern.colt.matrix.DoubleMatrix1D
movingAverage(cern.colt.matrix.DoubleMatrix1D m, int windowSize)
Simple moving average that sums the points "backwards".
-
-
-
Method Detail
-
movingAverage
public static cern.colt.matrix.DoubleMatrix1D movingAverage(cern.colt.matrix.DoubleMatrix1D m, int windowSize)
Simple moving average that sums the points "backwards".- Parameters:
m
-windowSize
-- Returns:
-
loessFit
public static cern.colt.matrix.DoubleMatrix2D loessFit(cern.colt.matrix.DoubleMatrix2D xy)
- Parameters:
xy
-- Returns:
- loessFit with default bandwitdh
-
loessFit
public static cern.colt.matrix.DoubleMatrix2D loessFit(cern.colt.matrix.DoubleMatrix2D xy, double bandwidth)
Computes a loess regression line to fit the data- Parameters:
xy
- data to be fitbandwidth
- 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 valuesy
- the training set of y valuesxInterpolate
- the set of x values to interpolate- Returns:
- yInterpolate the interpolated set of y values
-
-