baseCode.math
Class Stats

java.lang.Object
  extended bybaseCode.math.Stats

public class Stats
extends java.lang.Object

Miscellaneous functions used for statistical analysis. Some are optimized or specialized versions of methods that can be found elsewhere.

Version:
$Id: Stats.java,v 1.10 2004/07/27 03:18:58 pavlidis Exp $
Author:
Paul Pavlidis
See Also:
cern.jet.math , cern.jet.stat

Copyright (c) 2004

Columbia University


Method Summary
static cern.colt.list.DoubleArrayList cdf(cern.colt.list.DoubleArrayList x)
          Convert an array into a cumulative density function (CDF).
static cern.colt.list.DoubleArrayList cumulate(cern.colt.list.DoubleArrayList x)
          Convert an array into a cumulative array.
static cern.colt.list.DoubleArrayList cumulateRight(cern.colt.list.DoubleArrayList x)
          Convert an array into a cumulative array.
static double cv(cern.colt.list.DoubleArrayList data)
          Compute the coefficient of variation of an array (standard deviation / mean)
static boolean isValidFraction(double value)
          Test whether a value is a valid fractional or probability value.
static double meanAboveQuantile(int index, double[] array, int effectiveSize)
          calculate the mean of the values above (NOT greater or equal to) a particular index rank of an array.
static cern.colt.list.DoubleArrayList normalize(cern.colt.list.DoubleArrayList x)
          Adjust the elements of an array so they total to 1.0.
static cern.colt.list.DoubleArrayList normalize(cern.colt.list.DoubleArrayList x, double normfactor)
          Divide the elements of an array by a given factor.
static double quantile(int index, double[] values, int effectiveSize)
          Given a double array, calculate the quantile requested.
static double range(cern.colt.list.DoubleArrayList data)
          Compute the range of an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isValidFraction

public static boolean isValidFraction(double value)
Test whether a value is a valid fractional or probability value.

Parameters:
value -
Returns:
true if the value is in the interval 0 to 1.

cv

public static double cv(cern.colt.list.DoubleArrayList data)
Compute the coefficient of variation of an array (standard deviation / mean)

Parameters:
data - DoubleArrayList
Returns:
the cv

cumulate

public static cern.colt.list.DoubleArrayList cumulate(cern.colt.list.DoubleArrayList x)
Convert an array into a cumulative array. Summing is from the left hand side. Use this to make CDFs where the concern is the left tail.

Parameters:
x - DoubleArrayList
Returns:
cern.colt.list.DoubleArrayList

cumulateRight

public static cern.colt.list.DoubleArrayList cumulateRight(cern.colt.list.DoubleArrayList x)
Convert an array into a cumulative array. Summing is from the right hand side. This is useful for creating upper-tail cumulative density histograms from count histograms, where the upper tail is expected to have very small numbers that could be lost to rounding.

Parameters:
x - the array of data to be cumulated.
Returns:
cern.colt.list.DoubleArrayList

cdf

public static cern.colt.list.DoubleArrayList cdf(cern.colt.list.DoubleArrayList x)
Convert an array into a cumulative density function (CDF). This assumes that the input contains counts representing the distribution in question.

Parameters:
x - The input of counts (i.e. a histogram).
Returns:
DoubleArrayList the CDF.

normalize

public static cern.colt.list.DoubleArrayList normalize(cern.colt.list.DoubleArrayList x,
                                                       double normfactor)
Divide the elements of an array by a given factor.

Parameters:
x - Input array.
normfactor - double
Returns:
Normalized array.

normalize

public static cern.colt.list.DoubleArrayList normalize(cern.colt.list.DoubleArrayList x)
Adjust the elements of an array so they total to 1.0.

Parameters:
x - Input array.
Returns:
Normalized array.

meanAboveQuantile

public static double meanAboveQuantile(int index,
                                       double[] array,
                                       int effectiveSize)
calculate the mean of the values above (NOT greater or equal to) a particular index rank of an array. Quantile must be a value from 0 to 100.

Parameters:
index - the rank of the value we wish to average above.
array - Array for which we want to get the quantile.
effectiveSize - The size of the array, not including NaNs.
Returns:
double
See Also:
DescriptiveWithMissing.meanAboveQuantile(int, cern.colt.list.DoubleArrayList)

range

public static double range(cern.colt.list.DoubleArrayList data)
Compute the range of an array.

Parameters:
data - DoubleArrayList
Returns:
double

quantile

public static double quantile(int index,
                              double[] values,
                              int effectiveSize)
Given a double array, calculate the quantile requested. Note that no interpolation is done.

Parameters:
index - - the rank of the value we wish to get. Thus if we have 200 items in the array, and want the median, we should enter 100.
values - double[] - array of data we want quantile of
effectiveSize - int the effective size of the array
Returns:
double the value at the requested quantile
See Also:
DescriptiveWithMissing.quantile(cern.colt.list.DoubleArrayList, double)


Copyright © 2003-2005 Columbia University. All Rights Reserved.