net.aavalla.utils.general
Class Statistics

java.lang.Object
  extended by net.aavalla.utils.general.Statistics

public class Statistics
extends java.lang.Object

This class contains static methods for statistical analysis. The class is thread safe.

Author:
Lari Natri

Nested Class Summary
static class Statistics.TailedType
           
 
Constructor Summary
Statistics()
           
 
Method Summary
static void emptyFactorialCache()
          Empties the factorial cache to free memory.
static long factorial(int n)
          Calculates the factorial of parameter.
static double fisherExactTest(int k, int N, int m, int n, Statistics.TailedType tailed)
          Fisher exact test.
static double hyperGeomTest(int k, int N, int m, int n)
          Hypergeometric test.
 
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

factorial

public static long factorial(int n)
Calculates the factorial of parameter. Result might be imprecise with large values.

Parameters:
n - number (>=0) to calculate the factorial from
Returns:
n!
Throws:
java.lang.IllegalArgumentException - if parameter < 0

fisherExactTest

public static double fisherExactTest(int k,
                                     int N,
                                     int m,
                                     int n,
                                     Statistics.TailedType tailed)
Fisher exact test.

Parameters:
k - hits acquired
N - total number of items
m - maximum number of possible hits
n - number of tests done
tailed - type of tailed test to execute
Returns:
p-value
Throws:
java.lang.IllegalArgumentException - if parameter values are illegal

hyperGeomTest

public static double hyperGeomTest(int k,
                                   int N,
                                   int m,
                                   int n)
Hypergeometric test.

Parameters:
k - hits acquired
N - total number of items
m - maximum number of possible hits
n - number of tests done
Returns:
probability
Throws:
java.lang.IllegalArgumentException - if parameter values are illegal

emptyFactorialCache

public static void emptyFactorialCache()
Empties the factorial cache to free memory. Should only be called if very big factorials have been calculated and factorials of similar size are not needed in the near future.