org.akutan.utilities
Class Statistics

java.lang.Object
  extended by org.akutan.utilities.Statistics

public class Statistics
extends java.lang.Object

Class that wraps the colt descriptive statistics class and provides a few extras along the same vein.

Since:
14 December 2007

Constructor Summary
Statistics()
           
 
Method Summary
static double annualizeMean(double mean)
          Return the simple compounded annualization of the mean monthly return and convert from a decimal to a percent.
static double annualizeStdDev(double sigma)
          Annualize the monthly standard deviation and convert from a decimal to a percent.
static double beta(cern.colt.list.DoubleArrayList l1, cern.colt.list.DoubleArrayList l2)
          Called to compute the beta of series 1 with respect to series 2.
static double chiSquared(double n, double x)
          Returns the probability density function for the chi squared distribution for n degrees of freedom at x.
static double correlation(cern.colt.list.DoubleArrayList l1, cern.colt.list.DoubleArrayList l2)
          Compute the correlation of the series in the two lists
static double erfinv(double y)
          Inverse error function from the Scilab source code
static double kendallsTau(cern.colt.list.DoubleArrayList l1, cern.colt.list.DoubleArrayList l2)
          Compute kendall's tau for the two seriesthe sample covariance.
static double makePercent(double decimal)
          Converts a decimal to a percent.
static double mean(cern.colt.list.DoubleArrayList l)
          Compute the arithmetic mean of a list
static double mean(int num, double sumx)
          Compute the mean from a sum of the values and the count.
static double stddev(cern.colt.list.DoubleArrayList list)
          Compute the standard deviation using the code in colt
static double stddev(int num, double sumx, double sumx2)
          Compute the standard deviation given the number of values, the sum of the values and the sum of the values squared.
static double variance(int num, double sumx, double sumx2)
          Compute the variance of a sequence of values from the number of values, the sum of the values and the sum of the values squared.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statistics

public Statistics()
Method Detail

erfinv

public static double erfinv(double y)
Inverse error function from the Scilab source code

Parameters:
y -
Returns:
The inverse error function for the value y

makePercent

public static double makePercent(double decimal)
Converts a decimal to a percent.

Parameters:
decimal - input
Returns:
Input value as a percent ( 0.20 = 20.0%)

annualizeMean

public static double annualizeMean(double mean)
Return the simple compounded annualization of the mean monthly return and convert from a decimal to a percent.

Parameters:
mean - Monthly mean return as a decimal
Returns:
Annualized (monthly compounding) mean returned as a percent

annualizeStdDev

public static double annualizeStdDev(double sigma)
Annualize the monthly standard deviation and convert from a decimal to a percent.

Parameters:
sigma - Monthly standard deviation as a decimal
Returns:
Annualized standard deviation returned as a percent

correlation

public static double correlation(cern.colt.list.DoubleArrayList l1,
                                 cern.colt.list.DoubleArrayList l2)
Compute the correlation of the series in the two lists

Parameters:
l1 - List of time series points
l2 - List of time series points
Returns:
covariance between the two lists

kendallsTau

public static double kendallsTau(cern.colt.list.DoubleArrayList l1,
                                 cern.colt.list.DoubleArrayList l2)
Compute kendall's tau for the two seriesthe sample covariance. Kendall's tau is a robust method to compute the correlation between two series in the presence of outliers. Given Kendall's tau, the correlation between the two series is p = sin(tau * pi/2).

Parameters:
l1 - List of time series points
l2 - List of time series points
Returns:
kendall's tau
Throws:
java.lang.IllegalArgumentException - if the lengths of the two series are different

beta

public static double beta(cern.colt.list.DoubleArrayList l1,
                          cern.colt.list.DoubleArrayList l2)
Called to compute the beta of series 1 with respect to series 2.

Parameters:
l1 - List of dependent series points
l2 - List of independent series points
Returns:
beta of dependent series to independent series

mean

public static double mean(cern.colt.list.DoubleArrayList l)
Compute the arithmetic mean of a list

Parameters:
l - List of time series points
Returns:
Arithmetic mean of points on the list

mean

public static double mean(int num,
                          double sumx)
Compute the mean from a sum of the values and the count.

Parameters:
num - Number of values
sumx - Sum of values
Returns:
Arithmetic mean of the series

stddev

public static double stddev(int num,
                            double sumx,
                            double sumx2)
Compute the standard deviation given the number of values, the sum of the values and the sum of the values squared.

Parameters:
num - Number of values
sumx - Sum of values
sumx2 - Sum of squared values
Returns:
Standard deviation of the series

variance

public static double variance(int num,
                              double sumx,
                              double sumx2)
Compute the variance of a sequence of values from the number of values, the sum of the values and the sum of the values squared.

Parameters:
num - Number of values
sumx - Sum of values
sumx2 - Sum of squared values
Returns:
Variance of the series

stddev

public static double stddev(cern.colt.list.DoubleArrayList list)
Compute the standard deviation using the code in colt

Parameters:
list - List of values
Returns:
Standard deviation of the values on the list

chiSquared

public static double chiSquared(double n,
                                double x)
Returns the probability density function for the chi squared distribution for n degrees of freedom at x.

Parameters:
n - Number of degrees of freedom
x - Point on the distribution
Returns:
PDF for Chi squared distribution at x with n degrees of freedom