com.kutsyy.util
Class Rnd

java.lang.Object
  |
  +--com.kutsyy.util.Rnd

public final class Rnd
extends Object

Collection of methods in this class, generate random variables. Some methods call other, but most are stand alone.

Documentation to be added.


Requires Colt library
The random engine is of mose 1e1000
Created by Vadim Kutsyy

Author:
Vadim Kutsyy

Field Summary
private static long MODLUS
           
private static long MULT1
           
private static long MULT2
           
private static double remainder
           
private static int remaining
           
private static MersenneTwister rnd
           
private static long[] zrng
           
 
Constructor Summary
Rnd()
           
 
Method Summary
static double beta(double alpha1, double alpha2)
          Be(alpha1, alpha2)
static double[] beta(int n, double alpha1, double alpha2)
          Be(alpha1, alpha2)
static int binomial_int(double p)
          Binomial(p)
static int[] binomial_int(int n, int p)
          Binomial(p)
static boolean binomial(double p)
          Binomial(p)
static boolean[] binomial(int n, double p)
          Binomial(p)
static double exp(double lambda)
          Exponential(lambda)
static double[] exp(int n, double lambda)
          Exponential(lambda)
static double gamma(double alpha, double beta)
          Gamma(alpha,beta)
static double[] gamma(int n, double alpha, double beta)
          Gamma(alpha,beta)
private static double gauss()
          Insert the method's description here.
static int geometric(double p)
          Geometric(p)
static int[] geometric(int n, double p)
          Geometric(p)
static double lognor(double mu, double sigma)
          Insert the method's description here.
static double[] lognor(int n, double mu, double sigma)
          Insert the method's description here.
static double[] mvnor_sqrtSigma(double[][] sqrtSigma)
          Insert the method's description here.
static double[] mvnor(double[][] sigma)
          Insert the method's description here.
static double[] mvnor(double[] mu, double[][] sigma)
          Insert the method's description here.
static double[] mvnor(double mu, double[][] sigma)
          Insert the method's description here.
static double[][] mvnor(int n, double[][] sigma)
          Insert the method's description here.
static double[][] mvnor(int n, double[] mu, double[][] sigma)
          Insert the method's description here.
static double[][] mvnor(int n, double mu, double[][] sigma)
          Insert the method's description here.
static double[] mvntrc(double[] low, double[] high, double[][] sigma)
          Insert the method's description here.
static double[][] mvntrc(int n, double[] low, double[] high, double[][] sigma)
          Insert the method's description here.
static double[] mvntrcChol(double[] low, double[] high, double[][] sqrtSigma)
          Insert the method's description here.
static int negbinomial(int s, double p)
          Insert the method's description here.
static int[] negbinomial(int n, int s, double p)
          Insert the method's description here.
static double nor()
          Insert the method's description here.
static double nor(double mu, double sd)
          Insert the method's description here.
static double[] nor(int n)
          Insert the method's description here.
static double[] nor(int n, double mu, double sd)
          Insert the method's description here.
static double[] norOrdered(int n)
          Insert the method's description here.
static double ntrc(double low)
          Insert the method's description here.
static double ntrc(double low, double high)
          Insert the method's description here.
static double ntrc(double low, double high, double mu, double sd)
          Insert the method's description here.
static double[] ntrc(int n, double low, double high)
          Insert the method's description here.
static double[] ntrc(int n, double low, double high, double mu, double sd)
          Insert the method's description here.
static int poisson(double lambda)
          Insert the method's description here.
static int[] poisson(int n, double lambda)
          Insert the method's description here.
private static double rand(int stream)
          Insert the method's description here.
static double triang(double c)
          Insert the method's description here.
static double triang(double a, double b, double c)
          Insert the method's description here.
static double[] triang(int n, double c)
          Insert the method's description here.
static double[] triang(int n, double a, double b, double c)
          Insert the method's description here.
static double unif()
          Insert the method's description here.
static double unif(double[] low, double[] high)
          Insert the method's description here.
static double unif(double a, double b)
          Insert the method's description here.
static double[] unif(int n)
          Insert the method's description here.
static double[] unif(int n, double a, double b)
          Insert the method's description here.
static int unifDiscrete(int m)
          Insert the method's description here.
static double weibull(double eta, double beta)
          generate single weibull(eta,betta) random variable; Creation date: (1/26/00 1:39:51 PM)
static double[] weibull(int n, double eta, double beta)
          generate array(n) if weibull(eta,betta) random variables; Creation date: (1/26/00 1:39:51 PM)
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

zrng

private static final long[] zrng

MODLUS

private static final long MODLUS

MULT1

private static final long MULT1

MULT2

private static final long MULT2

remaining

private static int remaining

remainder

private static double remainder

rnd

private static MersenneTwister rnd
Constructor Detail

Rnd

public Rnd()
Method Detail

beta

public static double beta(double alpha1,
                          double alpha2)
Be(alpha1, alpha2)
Parameters:
alpha1 - alpha1
alpha2 - alpha2
Returns:
Be(alpha1, alpha2)

beta

public static double[] beta(int n,
                            double alpha1,
                            double alpha2)
Be(alpha1, alpha2)
Parameters:
n - number of variable to generate
alpha1 - alpha1
alpha2 - alpha2
Returns:
vector of Be(alpha1, alpha2)

binomial

public static boolean binomial(double p)
Binomial(p)
Parameters:
p - p
Returns:
Binomial(p)

binomial

public static boolean[] binomial(int n,
                                 double p)
Binomial(p)
Parameters:
n - number of variables to generate
p - p
Returns:
vector of Binomial(p)

binomial_int

public static int binomial_int(double p)
Binomial(p)
Parameters:
p - p
Returns:
Binomial(p)

binomial_int

public static int[] binomial_int(int n,
                                 int p)
Binomial(p)
Parameters:
n - number of variables to generate
p - p
Returns:
vector of Binomial(p)

exp

public static double exp(double lambda)
Exponential(lambda)
Parameters:
lambda - lambda
Returns:
Exponential(lambda)

exp

public static double[] exp(int n,
                           double lambda)
Exponential(lambda)
Parameters:
n - number of variables to generate
lambda - lambda
Returns:
vector of Exponential(lambda)

gamma

public static double gamma(double alpha,
                           double beta)
Gamma(alpha,beta)
Parameters:
alpha - alpha
beta - beta
Returns:
Gamma(alpha,beta)

gamma

public static double[] gamma(int n,
                             double alpha,
                             double beta)
Gamma(alpha,beta)
Parameters:
n - number of variables to generate
alpha - alpha
beta - beta
Returns:
vector Gamma(alpha,beta)

geometric

public static int geometric(double p)
Geometric(p)
Parameters:
p - p
Returns:
Geometric(p)

geometric

public static int[] geometric(int n,
                              double p)
Geometric(p)
Parameters:
n - number of variables to generate
p - p
Returns:
vector of Geometric(p)

lognor

public static double lognor(double mu,
                            double sigma)
Insert the method's description here. Creation date: (1/26/00 11:45:20 AM)
Parameters:
mu - double
sigma - double
Returns:
double

lognor

public static double[] lognor(int n,
                              double mu,
                              double sigma)
Insert the method's description here. Creation date: (1/26/00 11:46:29 AM)
Parameters:
n - number of variables to generate
mu - double
sigma - double
Returns:
double[]

mvnor

public static double[] mvnor(double[][] sigma)
Insert the method's description here. Creation date: (1/26/00 1:09:14 PM)
Parameters:
sigma - Description of Parameter
Returns:
double[]

mvnor

public static double[] mvnor(double[] mu,
                             double[][] sigma)
Insert the method's description here. Creation date: (1/26/00 1:32:45 PM)
Parameters:
mu - double
sigma - double[][]
Returns:
double[]

mvnor

public static double[] mvnor(double mu,
                             double[][] sigma)
Insert the method's description here. Creation date: (1/26/00 1:32:45 PM)
Parameters:
mu - double
sigma - double[][]
Returns:
double[]

mvnor

public static double[][] mvnor(int n,
                               double[][] sigma)
Insert the method's description here. Creation date: (1/26/00 1:09:14 PM)
Parameters:
n - number of variables to generate
sigma - Description of Parameter
Returns:
double[]

mvnor

public static double[][] mvnor(int n,
                               double[] mu,
                               double[][] sigma)
Insert the method's description here. Creation date: (1/26/00 1:09:14 PM)
Parameters:
n - number of variables to generate
mu - Description of Parameter
sigma - Description of Parameter
Returns:
double[]

mvnor

public static double[][] mvnor(int n,
                               double mu,
                               double[][] sigma)
Insert the method's description here. Creation date: (1/26/00 1:09:14 PM)
Parameters:
n - number of variables to generate
mu - Description of Parameter
sigma - Description of Parameter
Returns:
double[]

mvnor_sqrtSigma

public static double[] mvnor_sqrtSigma(double[][] sqrtSigma)
Insert the method's description here. Creation date: (1/26/00 1:07:50 PM)
Parameters:
sqrtSigma - double[][]
Returns:
double[]

mvntrc

public static double[] mvntrc(double[] low,
                              double[] high,
                              double[][] sigma)
Insert the method's description here. Creation date: (2/10/00 3:03:10 PM)
Parameters:
low - double[]
high - double[]
sigma - Description of Parameter
Returns:
double[]

mvntrc

public static double[][] mvntrc(int n,
                                double[] low,
                                double[] high,
                                double[][] sigma)
Insert the method's description here. Creation date: (2/10/00 3:05:54 PM)
Parameters:
n - number of variables to generate
low - double[]
high - double[]
sigma - double[][]
Returns:
double[][]

mvntrcChol

public static double[] mvntrcChol(double[] low,
                                  double[] high,
                                  double[][] sqrtSigma)
Insert the method's description here. Creation date: (2/10/00 3:03:10 PM)
Parameters:
low - double[]
high - double[]
sqrtSigma - Description of Parameter
Returns:
double[]

negbinomial

public static int negbinomial(int s,
                              double p)
Insert the method's description here. Creation date: (1/26/00 12:42:53 PM)
Parameters:
s - int
p - double
Returns:
int

negbinomial

public static int[] negbinomial(int n,
                                int s,
                                double p)
Insert the method's description here. Creation date: (1/26/00 12:46:09 PM)
Parameters:
n - number of variables to generate
s - int
p - double
Returns:
int[]

nor

public static double nor()
Insert the method's description here. Creation date: (1/24/00 9:00:19 AM)
Returns:
double

nor

public static double nor(double mu,
                         double sd)
Insert the method's description here. Creation date: (1/26/00 11:01:06 AM)
Parameters:
mu - double
sd - double
Returns:
double

nor

public static double[] nor(int n)
Insert the method's description here. Creation date: (1/25/00 4:25:28 PM)
Parameters:
n - number of variables to generate
Returns:
double[]

nor

public static double[] nor(int n,
                           double mu,
                           double sd)
Insert the method's description here. Creation date: (1/26/00 11:02:44 AM)
Parameters:
n - int
mu - double
sd - double
Returns:
double[]

norOrdered

public static double[] norOrdered(int n)
Insert the method's description here. Creation date: (3/6/00 11:42:39 AM)
Parameters:
n - number of variables to generate
Returns:
double[]

ntrc

public static double ntrc(double low)
Insert the method's description here. Creation date: (2/10/00 4:30:30 PM)
Parameters:
low - double
Returns:
double

ntrc

public static double ntrc(double low,
                          double high)
Insert the method's description here. Creation date: (2/10/00 2:31:07 PM)
Parameters:
low - double
high - double
Returns:
double

ntrc

public static double ntrc(double low,
                          double high,
                          double mu,
                          double sd)
Insert the method's description here. Creation date: (2/10/00 2:32:46 PM)
Parameters:
low - double
high - double
mu - double
sd - double
Returns:
double

ntrc

public static double[] ntrc(int n,
                            double low,
                            double high)
Insert the method's description here. Creation date: (2/10/00 2:36:04 PM)
Parameters:
n - number of variables to generate
low - double[]
high - double[]
Returns:
double[]

ntrc

public static double[] ntrc(int n,
                            double low,
                            double high,
                            double mu,
                            double sd)
Insert the method's description here. Creation date: (2/10/00 2:35:15 PM)
Parameters:
n - number of variables to generate
low - double[]
high - double[]
mu - double[]
sd - double[][]
Returns:
double[]

poisson

public static int poisson(double lambda)
Insert the method's description here. Creation date: (1/26/00 12:47:13 PM)
Parameters:
lambda - double
Returns:
int

poisson

public static int[] poisson(int n,
                            double lambda)
Insert the method's description here. Creation date: (1/26/00 12:50:34 PM)
Parameters:
n - number of variables to generate
lambda - double
Returns:
int[]

triang

public static double triang(double c)
Insert the method's description here. Creation date: (2/10/00 2:15:05 PM)
Parameters:
c - double
Returns:
double

triang

public static double triang(double a,
                            double b,
                            double c)
Insert the method's description here. Creation date: (2/10/00 2:17:32 PM)
Parameters:
a - double
b - double
c - double
Returns:
double

triang

public static double[] triang(int n,
                              double c)
Insert the method's description here. Creation date: (2/10/00 2:18:21 PM)
Parameters:
n - number of variables to generate
c - double
Returns:
double[]

triang

public static double[] triang(int n,
                              double a,
                              double b,
                              double c)
Insert the method's description here. Creation date: (2/10/00 2:17:52 PM)
Parameters:
n - number of variables to generate
a - double
b - double
c - double
Returns:
double[]

unif

public static double unif()
Insert the method's description here. Creation date: (1/26/00 11:03:40 AM)
Returns:
double

unif

public static final double unif(double[] low,
                                double[] high)
Insert the method's description here. Creation date: (3/6/00 4:04:19 PM)
Parameters:
low - double[]
high - double[]
Returns:
double

unif

public static double unif(double a,
                          double b)
Insert the method's description here. Creation date: (1/26/00 11:06:43 AM)
Parameters:
a - double
b - double
Returns:
double

unif

public static double[] unif(int n)
Insert the method's description here. Creation date: (1/26/00 11:08:33 AM)
Parameters:
n - number of variables to generate
Returns:
double[]

unif

public static double[] unif(int n,
                            double a,
                            double b)
Insert the method's description here. Creation date: (1/26/00 11:09:26 AM)
Parameters:
n - number of variables to generate
a - double
b - double
Returns:
double[]

unifDiscrete

public static int unifDiscrete(int m)
Insert the method's description here. Creation date: (3/6/00 12:57:13 PM)
Parameters:
m - int
Returns:
int

weibull

public static double weibull(double eta,
                             double beta)
generate single weibull(eta,betta) random variable; Creation date: (1/26/00 1:39:51 PM)
Parameters:
eta - double - scale parameter
beta - double - shape parameter
Returns:
double - random variables

weibull

public static double[] weibull(int n,
                               double eta,
                               double beta)
generate array(n) if weibull(eta,betta) random variables; Creation date: (1/26/00 1:39:51 PM)
Parameters:
n - number of variables to generate
eta - double - scale parameter
beta - double - shape parameter
Returns:
double[n] - random variables

gauss

private static double gauss()
Insert the method's description here. Creation date: (3/3/00 9:49:44 AM)
Returns:
double

rand

private static double rand(int stream)
Insert the method's description here. Creation date: (3/3/00 9:43:11 AM)
Parameters:
stream - int
Returns:
double