Package ubic.basecode.math
Class Smooth
java.lang.Object
ubic.basecode.math.Smooth
Methods for moving averages, loess
- Author:
- paul, ptan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 DoubleMatrix2D
static DoubleMatrix2D
loessFit
(DoubleMatrix2D xy, double bandwidth) Computes a loess regression line to fit the datastatic DoubleMatrix1D
movingAverage
(DoubleMatrix1D m, int windowSize) Simple moving average that sums the points "backwards".
-
Constructor Details
-
Smooth
public Smooth()
-
-
Method Details
-
movingAverage
Simple moving average that sums the points "backwards".- Parameters:
m
-windowSize
-- Returns:
-
loessFit
- Parameters:
xy
-- Returns:
- loessFit with default bandwitdh
-
loessFit
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
-