jstats
Class Mean

java.lang.Object
  extended byjstats.Mean

public abstract class Mean
extends java.lang.Object

Static methods for calculating means and other measures of center.

Author:
Justin Scheiber, David Edelstein

Constructor Summary
Mean()
           
 
Method Summary
static double arithmeticMean(double[] values)
          Calculate the arithmetic mean from an array of doubles.
static double binomialMean(double probability, long trials)
          Calculate a binomial mean.
static double geometricMean(double[] values)
          Calculates the geometic mean.
static double grandMean(double[] weights, double[] means)
          Calculates the grand mean.
static double harmonicMean(double[] values)
          Calculates a harmonic mean.
static double hypergeometricMean(double n, double a, double b)
           
static double median(double[] values)
          Computes a median of an array of values.
static double midrange(double[] values)
          Computes the midrange (the value exactly between the lowest and highest values) from an array of doubles.
static double probabilityMean(double probability, double[] values)
          Calculates the mean of a probability distribution.
static double weightedMean(double[] weights, double[] values)
          Caculate a weighted mean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mean

public Mean()
Method Detail

median

public static double median(double[] values)
                     throws StatisticException
Computes a median of an array of values.

Parameters:
values - an array of doubles
Returns:
the median of the values array
Throws:
StatisticException - for an empty array

midrange

public static double midrange(double[] values)
                       throws StatisticException
Computes the midrange (the value exactly between the lowest and highest values) from an array of doubles.

Parameters:
values - an array of doubles
Returns:
the midrange of the values array
Throws:
StatisticException - for an empty array

arithmeticMean

public static double arithmeticMean(double[] values)
                             throws StatisticException
Calculate the arithmetic mean from an array of doubles.

Parameters:
values - An array of doubles.
Returns:
arithmetic mean
Throws:
StatisticException - for empty array

binomialMean

public static double binomialMean(double probability,
                                  long trials)
                           throws StatisticException
Calculate a binomial mean.

Parameters:
probability -
trials -
Returns:
the binomial mean
Throws:
StatisticException

geometricMean

public static double geometricMean(double[] values)
                            throws StatisticException
Calculates the geometic mean. Used to average ratios.

Parameters:
values - An array of doubles containing ratios.
Returns:
geometic mean
Throws:
StatisticException

grandMean

public static double grandMean(double[] weights,
                               double[] means)
                        throws StatisticException
Calculates the grand mean. Used to average multiple means with weights.

Parameters:
weights - An array of doubles containing weights that correspond to each of the means.
means - An array of doubles containing means from different observations.
Returns:
grand mean
Throws:
StatisticException

harmonicMean

public static double harmonicMean(double[] values)
                           throws StatisticException
Calculates a harmonic mean. Used to average frequencies.

Parameters:
values - An array of doubles containing frequencies.
Returns:
harmonic mean
Throws:
StatisticException

hypergeometricMean

public static double hypergeometricMean(double n,
                                        double a,
                                        double b)

probabilityMean

public static double probabilityMean(double probability,
                                     double[] values)
                              throws StatisticException
Calculates the mean of a probability distribution.

Parameters:
probability -
values -
Returns:
the mean of a probability distribution
Throws:
StatisticException

weightedMean

public static double weightedMean(double[] weights,
                                  double[] values)
                           throws StatisticException
Caculate a weighted mean. Used when the values in a set of data do not share equal importance.

Parameters:
weights - Weights to use when calculating the mean.
values - Data on which to perform the weighted mean.
Returns:
weighted mean
Throws:
StatisticException