edu.stanford.rsl.konrad.utils
Class StatisticsUtil

java.lang.Object
  extended by edu.stanford.rsl.konrad.utils.StatisticsUtil

public abstract class StatisticsUtil
extends java.lang.Object


Constructor Summary
StatisticsUtil()
           
 
Method Summary
static double logfactorial(int k)
          Computes ln(k!) using the Stirling approximation.
static void main(java.lang.String[] args)
           
static int poissonRandomNumber(double lambda)
          Generates a Poisson distributed random number.
static int poissonRandomNumberBig(double lambda)
          Generates a Poisson distributed random number.
static int poissonRandomNumberSmall(double lambda)
          Generates a Poisson distributed random number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatisticsUtil

public StatisticsUtil()
Method Detail

poissonRandomNumber

public static int poissonRandomNumber(double lambda)
Generates a Poisson distributed random number. The Poisson distribution is definded by the number lambda. The distribution has mean lambda and standard deviation of Math.sqrt(lambda).
If lambda is smaller than 200 the value is determined by cumulative statistics, otherwise an approximation is used. Time measurements showed that the approximation used here outperforms the implementation in Matlab 2008.

poisson distribution

Parameters:
lambda -
Returns:
a random number drawn from the Poisson distribution
See Also:
poissonRandomNumberSmall(double), poissonRandomNumberBig(double)

poissonRandomNumberSmall

public static int poissonRandomNumberSmall(double lambda)
Generates a Poisson distributed random number. The Poisson distribution is definded by the number lambda. The distribution has mean lambda and standard deviation of Math.sqrt(lambda).
Computation is based on cumulative statistics and gets slow with greater values of lambda.

poisson distribution

Parameters:
lambda -
Returns:
a random number from the Poisson distribution

logfactorial

public static double logfactorial(int k)
Computes ln(k!) using the Stirling approximation.
(cf. J.H. Ahrens, U. Dieter. Computer Generation of Poission Deviates from Modified Normal Distributions. ACM Transactions on Mathematical Software (TOMS). 8(2):163-79. 1982.)

Parameters:
k - the k
Returns:
ln(k!)

poissonRandomNumberBig

public static int poissonRandomNumberBig(double lambda)
Generates a Poisson distributed random number. The Poisson distribution is definded by the number lambda. The distribution has mean lambda and standard deviation of Math.sqrt(lambda).
Uses the rejection algorithm after Atkinson (cf. A.C. Atkinson. The Computer Generation of Poisson Random Variables. Journal of the Royal Statistical Society. Series C (Applied Statistics) Vol. 28, No. 1 (1979), pp. 29-35)

poisson distribution

Parameters:
lambda -
Returns:
a random number from the Poisson distribution

main

public static void main(java.lang.String[] args)