Package org.terrier.utility
Class StaTools
- java.lang.Object
-
- org.terrier.utility.StaTools
-
public class StaTools extends java.lang.ObjectThis class implements a series of basic statistical functions.
-
-
Constructor Summary
Constructors Constructor Description StaTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublegeneralisedMean(double[] data, double p)Computes the generalized mean, which is a general version of mean and quadratic mean, generalized by parameter p.static doublegeometricMean(double[] data)Computes the geometric mean.static doubleharmonicMean(double[] data)Computes the harmonic mean.static doublemax(double[] a)Return the max of the specified arraystatic doublemax(double[] a, int offset, int length)Return the max of the specified arraystatic floatmax(float[] a)Return the max of the specified arraystatic intmax(int[] a)Return the max of the specified arraystatic doublemean(double[] data)The mean of an array of double values.static doublemean(double[] data, int start, int length, boolean ascending)The mean of a sub-array of an array of double values.static floatmean(float[] data)find mean of float[]static doublemean(int[] data)The mean of an array of integers.static doublemeanNonZero(double[] data)The mean of an array of doubles, only counting non-zero values.static doublemedian(double[] data)The median of an array of double values.static doublemin(double[] a)Return the min of the specified arraystatic floatmin(float[] a)Return the min of the specified arraystatic intmin(int[] a)Return the min of the specified arraystatic doublequadraticMean(double[] data)Computes the quadratic mean, also known as the root mean square.static doublestandardDeviation(double[] data)The standard deviation of an array of double values.static double[]standardNormalisation(double[] data)Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum.static float[]standardNormalisation(float[] data)Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum.static doublestdErrorOfTheMean(double[] data)This method returns the standard error of the mean for an array of data.static doublestirlingPower(double n, double m)This method provides the contract for implementing the Stirling formula for the power series.static doublesum(double[] data)The sum of an array of double.static intsum(int[] data)The sum of an array of integers.static intsum(int[] data, int length)The sum of an array of integers.static doublevariance(double[] data)The variance of an array of double values.
-
-
-
Method Detail
-
stirlingPower
public static double stirlingPower(double n, double m)This method provides the contract for implementing the Stirling formula for the power series.- Parameters:
n- The parameter of the Stirling formula.m- The parameter of the Stirling formula.- Returns:
- the approximation of the power series
-
stdErrorOfTheMean
public static double stdErrorOfTheMean(double[] data)
This method returns the standard error of the mean for an array of data.- Parameters:
data- The sampled data.- Returns:
- The standard error of the mean.
-
max
public static final int max(int[] a)
Return the max of the specified array- Parameters:
a- the array- Returns:
- the maximum value in the arrays
-
max
public static final double max(double[] a)
Return the max of the specified array- Parameters:
a- the array- Returns:
- the maximum value in the arrays
-
max
public static final double max(double[] a, int offset, int length)Return the max of the specified array- Parameters:
a- the arrayoffset- the offset in the array to start examining fromlength- how many items of the array to consider- Returns:
- the maximum value in the arrays
-
min
public static final double min(double[] a)
Return the min of the specified array- Parameters:
a- the array- Returns:
- the minimum value in the arrays
-
min
public static final int min(int[] a)
Return the min of the specified array- Parameters:
a- the array- Returns:
- the minimum value in the arrays
-
sum
public static int sum(int[] data)
The sum of an array of integers.- Parameters:
data- The integers.- Returns:
- The sum.
-
sum
public static int sum(int[] data, int length)The sum of an array of integers.- Parameters:
data- The integers.- Returns:
- The sum.
-
sum
public static double sum(double[] data)
The sum of an array of double.- Parameters:
data- The integers.- Returns:
- The sum.
-
mean
public static double mean(double[] data)
The mean of an array of double values.- Parameters:
data- The double values.- Returns:
- The mean.
-
mean
public static float mean(float[] data)
find mean of float[]- Parameters:
data-- Returns:
- mean
-
mean
public static double mean(double[] data, int start, int length, boolean ascending)The mean of a sub-array of an array of double values.- Parameters:
data- The array of double values.start- The starting index of the sub-array.length- The length of the sub-array.ascending- Is the starting index the left (true) or right (false) end of the sub-array?- Returns:
- The mean of the sub-array.
-
mean
public static double mean(int[] data)
The mean of an array of integers.- Parameters:
data- The array of integers.- Returns:
- The mean.
-
meanNonZero
public static double meanNonZero(double[] data)
The mean of an array of doubles, only counting non-zero values.- Parameters:
data- The array of integers.- Returns:
- The mean.
-
median
public static double median(double[] data)
The median of an array of double values.- Parameters:
data- The array of double values.- Returns:
- The median.
-
standardDeviation
public static double standardDeviation(double[] data)
The standard deviation of an array of double values.- Parameters:
data- The array of double values.- Returns:
- The standrad deviation.
-
variance
public static double variance(double[] data)
The variance of an array of double values.- Parameters:
data- The array of double values.- Returns:
- The variance.
-
harmonicMean
public static double harmonicMean(double[] data)
Computes the harmonic mean. This assumes that all values are > 0. See http://en.wikipedia.org/wiki/Harmonic_mean.
-
geometricMean
public static double geometricMean(double[] data)
Computes the geometric mean. This assumes that all values are > 0. See http://en.wikipedia.org/wiki/Geometric_mean.
-
quadraticMean
public static double quadraticMean(double[] data)
Computes the quadratic mean, also known as the root mean square. See http://en.wikipedia.org/wiki/Quadratic_mean.
-
generalisedMean
public static double generalisedMean(double[] data, double p)Computes the generalized mean, which is a general version of mean and quadratic mean, generalized by parameter p. See http://en.wikipedia.org/wiki/Generalized_mean.
-
standardNormalisation
public static double[] standardNormalisation(double[] data)
Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum. RETURNS THE SAME ARRAY OBJECT - i.e. changes are made in place.- Parameters:
data-
-
standardNormalisation
public static float[] standardNormalisation(float[] data)
Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum. RETURNS THE SAME ARRAY OBJECT - i.e. changes are made in place.- Parameters:
data-
-
min
public static final float min(float[] a)
Return the min of the specified array- Parameters:
a- the array- Returns:
- the minimum value in the arrays
-
max
public static final float max(float[] a)
Return the max of the specified array- Parameters:
a- the array- Returns:
- the maximum value in the arrays
-
-