papaya
Class Descriptive.Mean

java.lang.Object
  extended by papaya.Descriptive.Mean
Enclosing class:
Descriptive

public static class Descriptive.Mean
extends Object

Contains methods for computing the arithmetic, geometric, harmonic, trimmed, and winsorized means (among others).


Method Summary
static float arithmetic(float[] data)
          Returns the arithmetic mean of a data sequence; That is Sum( data[i] ) / data.length .
static float[] columnMean(float[][] data)
          Returns an array containing the arithmetic mean of each column of the input matrix.
static float geometric(float[] data)
          Returns the geometric mean of a data sequence.
static float geometric(int size, float sumOfLogarithms)
          Returns the geometric mean of a data sequence.
static float harmonic(float[] data)
          Returns the harmonic mean of a data sequence as Sum( 1.0 / data[i]).
static float harmonic(int size, float sumOfInversions)
          Returns the harmonic mean of a data sequence.
static float[] rowMean(float[][] data)
          Returns an array containing the arithmetic mean of each row of the input matrix.
static float trimmed(float[] sortedData, float mean, int left, int right)
          Returns the trimmed arithmetic mean of a sorted data sequence.
static float winsorized(float[] sortedData, float mean, int left, int right)
          Returns the winsorized mean of a sorted data sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

columnMean

public static float[] columnMean(float[][] data)
Returns an array containing the arithmetic mean of each column of the input matrix.


rowMean

public static float[] rowMean(float[][] data)
Returns an array containing the arithmetic mean of each row of the input matrix.


arithmetic

public static float arithmetic(float[] data)
Returns the arithmetic mean of a data sequence; That is Sum( data[i] ) / data.length .


geometric

public static float geometric(int size,
                              float sumOfLogarithms)
Returns the geometric mean of a data sequence. Note that for a geometric mean to be meaningful, the minimum of the data sequence must not be less or equal to zero.
The geometric mean is given by pow( Product( data[i] ), 1/size) which is equivalent to Math.exp( Sum( Log(data[i]) ) / size).

The latter version is used here is the former easily results in overflows.


geometric

public static float geometric(float[] data)
Returns the geometric mean of a data sequence. Note that for a geometric mean to be meaningful, the minimum of the data sequence must not be less or equal to zero.
The geometric mean is given by pow( Product( data[i] ), 1/data.size()). This method tries to avoid overflows at the expense of an equivalent but somewhat slow definition: geometricMean = Math.exp( Sum( Log(data[i]) ) / size).


harmonic

public static float harmonic(int size,
                             float sumOfInversions)
Returns the harmonic mean of a data sequence.

Parameters:
size - the number of elements in the data sequence.
sumOfInversions - Sum( 1.0 / data[i]).

harmonic

public static float harmonic(float[] data)
Returns the harmonic mean of a data sequence as Sum( 1.0 / data[i]).

Parameters:
data - array

trimmed

public static float trimmed(float[] sortedData,
                            float mean,
                            int left,
                            int right)
Returns the trimmed arithmetic mean of a sorted data sequence.

Parameters:
sortedData - the data sequence; must be sorted ascending.
mean - the mean of the (full) sorted data sequence.
left - the number of leading elements to trim.
right - the number of trailing elements to trim.

winsorized

public static float winsorized(float[] sortedData,
                               float mean,
                               int left,
                               int right)
Returns the winsorized mean of a sorted data sequence.

Parameters:
sortedData - the data sequence; must be sorted ascending.
mean - the mean of the (full) sorted data sequence.
left - the number of leading elements to trim.
right - the number of trailing elements to trim.


Processing library papaya by Adila Faruk. (C) 2014