Package net.sourceforge.jiu.util
Class Statistics
- java.lang.Object
-
- net.sourceforge.jiu.util.Statistics
-
public class Statistics extends Object
A number of static methods to compute statistical properties of an array of double values. Implements the computation of mean, variance and standard deviation fordouble
values.- Since:
- 0.11.0
- Author:
- Marco Schmidt
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Statistics()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
computeMean(double[] values)
Computes the mean value for the argument array.static double
computeMean(double[] values, int offset, int number)
Computes the mean value for some elements of the argument array.static double
computeStandardDeviation(double[] values)
Computes the standard deviation for the argument array of values.static double
computeStandardDeviation(double[] values, double mean)
Computes the standard deviation for the argument array of values.static double
computeStandardDeviation(double[] values, int offset, int number)
Computes the standard deviation for some of the argument array's values.static double
computeStandardDeviation(double[] values, int offset, int number, double mean)
Computes the standard deviation for some of the argument array's values.static double
computeVariance(double[] values)
Computes the variance for the argument array.static double
computeVariance(double[] values, double mean)
Computes the variance for some of the argument array's values.static double
computeVariance(double[] values, int offset, int number)
Computes the variance for some of the argument array's values.static double
computeVariance(double[] values, int offset, int number, double mean)
Computes the variance for some of the argument array's values.
-
-
-
Method Detail
-
computeMean
public static double computeMean(double[] values)
Computes the mean value for the argument array. Adds all values and divides them by the number of array elements.- Parameters:
values
- double array on which the mean is to be determined- Returns:
- computed mean value
- Throws:
IllegalArgumentException
- if the array has not at least one element
-
computeMean
public static double computeMean(double[] values, int offset, int number)
Computes the mean value for some elements of the argument array. Adds all values and divides them by the number of array elements.- Parameters:
values
- array from which elements are readoffset
- index of the first element to be usednumber
- number of elements to be used- Returns:
- computed mean value
- Throws:
IllegalArgumentException
- if the array has not at least one element
-
computeStandardDeviation
public static double computeStandardDeviation(double[] values)
Computes the standard deviation for the argument array of values.- Parameters:
values
- array from which elements are read- Returns:
- computed standard deviation
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeStandardDeviation
public static double computeStandardDeviation(double[] values, double mean)
Computes the standard deviation for the argument array of values. Reuses the mean value for that argument which must have been computed before.- Parameters:
values
- array from which elements are readmean
- the mean value for the array, possibly computed with a call tocomputeMean(double[])
.- Returns:
- computed standard deviation
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeStandardDeviation
public static double computeStandardDeviation(double[] values, int offset, int number)
Computes the standard deviation for some of the argument array's values. If you already have computed a mean value usingcomputeMean(double[], int, int)
, better callcomputeStandardDeviation(double[], int, int, double)
. Otherwise, this method has to compute mean again.- Parameters:
values
- array from which elements are readoffset
- first element to be usednumber
- number of elements used starting at values[offset]- Returns:
- computed standard deviation
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeStandardDeviation
public static double computeStandardDeviation(double[] values, int offset, int number, double mean)
Computes the standard deviation for some of the argument array's values. Use this version of the method if you already have a mean value, otherwise this method must be computed again.- Parameters:
values
- array from which elements are readoffset
- first element to be usednumber
- number of elements used starting at values[offset]mean
- value of the elements- Returns:
- computed standard deviation
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeVariance
public static double computeVariance(double[] values)
Computes the variance for the argument array.- Parameters:
values
- array from which elements are read- Returns:
- variance for the array elements
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeVariance
public static double computeVariance(double[] values, double mean)
Computes the variance for some of the argument array's values.- Parameters:
values
- array from which elements are readmean
- the mean for the array elements- Returns:
- variance for the array elements
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeVariance
public static double computeVariance(double[] values, int offset, int number)
Computes the variance for some of the argument array's values. If you already have computed a mean value usingcomputeMean(double[], int, int)
, better callcomputeVariance(double[], int, int, double)
. Otherwise, this method has to compute mean again.- Parameters:
values
- array from which elements are readoffset
- first element to be usednumber
- number of elements used starting at values[offset]- Returns:
- computed variance
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
computeVariance
public static double computeVariance(double[] values, int offset, int number, double mean)
Computes the variance for some of the argument array's values. Use this version of the method in case mean has already been computed.- Parameters:
values
- array from which elements are readoffset
- first element to be usednumber
- number of elements used starting at values[offset]mean
- the mean for the array elements- Returns:
- computed variance
- Throws:
IllegalArgumentException
- if the array has not at least two elements
-
-