public abstract class Statistics extends java.lang.Object
Constructor and Description |
---|
Statistics() |
Modifier and Type | Method and Description |
---|---|
static double |
calculateMean(java.util.Collection values)
Returns the mean of a collection of
Number objects. |
static double |
calculateMean(java.util.Collection values,
boolean includeNullAndNaN)
Returns the mean of a collection of
Number objects. |
static double |
calculateMean(java.lang.Number[] values)
Returns the mean of an array of numbers.
|
static double |
calculateMean(java.lang.Number[] values,
boolean includeNullAndNaN)
Returns the mean of an array of numbers.
|
static double |
calculateMedian(java.util.List values)
Calculates the median for a list of values (
Number objects). |
static double |
calculateMedian(java.util.List values,
boolean copyAndSort)
Calculates the median for a list of values (
Number objects). |
static double |
calculateMedian(java.util.List values,
int start,
int end)
Calculates the median for a sublist within a list of values
(
Number objects). |
static double |
calculateMedian(java.util.List values,
int start,
int end,
boolean copyAndSort)
Calculates the median for a sublist within a list of values
(
Number objects). |
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.
|
public Statistics()
public static double calculateMean(java.lang.Number[] values)
calculateMean(values, true)
.values
- the values (null
not permitted).public static double calculateMean(java.lang.Number[] values, boolean includeNullAndNaN)
values
- the values (null
not permitted).includeNullAndNaN
- a flag that controls whether or not
null
and Double.NaN
values are included
in the calculation (if either is present in the array, the result is
Double.NaN
).public static double calculateMean(java.util.Collection values)
Number
objects.values
- the values (null
not permitted).public static double calculateMean(java.util.Collection values, boolean includeNullAndNaN)
Number
objects.values
- the values (null
not permitted).includeNullAndNaN
- a flag that controls whether or not
null
and Double.NaN
values are included
in the calculation (if either is present in the array, the result is
Double.NaN
).public static double calculateMedian(java.util.List values)
Number
objects).
The list of values will be copied, and the copy sorted, before
calculating the median. To avoid this step (if your list of values
is already sorted), use the calculateMedian(List, boolean)
method.values
- the values (null
permitted).public static double calculateMedian(java.util.List values, boolean copyAndSort)
Number
objects).
If copyAndSort
is false
, the list is assumed
to be presorted in ascending order by value.values
- the values (null
permitted).copyAndSort
- a flag that controls whether the list of values is
copied and sorted.public static double calculateMedian(java.util.List values, int start, int end)
Number
objects).values
- the values, in any order (null
not permitted).start
- the start index.end
- the end index.public static double calculateMedian(java.util.List values, int start, int end, boolean copyAndSort)
Number
objects). The entire list will be sorted if the
ascending
argument is false
.values
- the values (null
not permitted).start
- the start index.end
- the end index.copyAndSort
- a flag that that controls whether the list of values
is copied and sorted.public static double getStdDev(java.lang.Number[] data)
data
- the data (null
or zero length array not
permitted).public static double[] getLinearFit(java.lang.Number[] xData, java.lang.Number[] yData)
xData
- the x-data (null
not permitted).yData
- the y-data (null
not permitted).public static double getSlope(java.lang.Number[] xData, java.lang.Number[] yData)
xData
- the x-values (null
not permitted).yData
- the y-values (null
not permitted).public static double getCorrelation(java.lang.Number[] data1, java.lang.Number[] data2)
Information about the correlation calculation was obtained from: http://trochim.human.cornell.edu/kb/statcorr.htm
data1
- the first dataset.data2
- the second dataset.public static double[][] getMovingAverage(java.lang.Number[] xData, java.lang.Number[] yData, int period)
xData
- an array of the x data.yData
- an array of the y data.period
- the number of data points to average