com.jrefinery.data
Class Statistics
java.lang.Object
|
+--com.jrefinery.data.Statistics
- public class Statistics
- extends java.lang.Object
A utility class that provides some simple statistical functions.
- Author:
- MW
Method Summary |
static double |
getAverage(java.lang.Number[] data)
Returns the average of a set of numbers. |
static double |
getCorrelation(java.lang.Number[] data1,
java.lang.Number[] data2)
Calculates the correlation between two datasets. |
static double[] |
getLinearFit(java.lang.Number[] xData,
java.lang.Number[] yData)
Fits a straight line to a set of (x, y) data, returning the slope and
intercept. |
static double[][] |
getMovingAverage(java.lang.Number[] xData,
java.lang.Number[] yData,
int period)
Returns a data set for a moving average on the data set passed in. |
static double |
getSlope(java.lang.Number[] xData,
java.lang.Number[] yData)
Finds the slope of a regression line using least squares. |
static double |
getStdDev(java.lang.Number[] data)
Returns the standard deviation of a set of numbers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Statistics
public Statistics()
getAverage
public static double getAverage(java.lang.Number[] data)
- Returns the average of a set of numbers.
- Parameters:
data
- the data.- Returns:
- the average of a set of numbers.
getStdDev
public static double getStdDev(java.lang.Number[] data)
- Returns the standard deviation of a set of numbers.
- Parameters:
data
- the data.- Returns:
- the standard deviation of a set of numbers.
getLinearFit
public static double[] getLinearFit(java.lang.Number[] xData,
java.lang.Number[] yData)
- Fits a straight line to a set of (x, y) data, returning the slope and
intercept.
- Parameters:
xData
- the x-data.yData
- the y-data.- Returns:
- a double array with the intercept in [0] and the slope in [1].
getSlope
public static double getSlope(java.lang.Number[] xData,
java.lang.Number[] yData)
- Finds the slope of a regression line using least squares.
- Parameters:
xData
- an array of Numbers (the x values).yData
- an array of Numbers (the y values).- Returns:
- the slope.
getCorrelation
public static double getCorrelation(java.lang.Number[] data1,
java.lang.Number[] data2)
- Calculates the correlation between two datasets.
- Parameters:
data1
- the first dataset.data2
- the second dataset.- Returns:
- the correlation between two datasets.
getMovingAverage
public static double[][] getMovingAverage(java.lang.Number[] xData,
java.lang.Number[] yData,
int period)
- Returns a data set for a moving average on the data set passed in.
- Parameters:
xData
- an array of the x data.yData
- an array of the y data.period
- the number of data points to average- Returns:
- a double[][] the length of the data set in the first dimension,
with two doubles for x and y in the second dimension