ThinkUI Data Generator 1.0.2 API

thinkui.datagen.util
Class Variate

java.lang.Object
  extended bythinkui.datagen.util.Variate

public final class Variate
extends java.lang.Object

This class implements routines to generate various distribution of random variates. The java.util.Random.nextDouble() method is used to generate uniform variates between 0.0 and 1.0 from which all other variates are derived.


Method Summary
static int getBernoulli(double dP)
          This function returns a bernoulli variate with a probability P of success.
static int getBinomial(double dP, int nT)
          This function returns a binomial variate of T bernoulli trails with probability P of success.
static double getExponential(double dMu)
          This function returns an exponential variate with mean 1/dMu.
static double getNormal(double dMean, double dStdDev)
          This function returns an approximate normal variate with the specified mean and standard deviation.
static double getNormalDouble()
          Returns the next pseudorandom, Gaussian ("normally") distributed double value between 0.0 and 1.0 (exclusive).
static int getPoison(double dLambda)
          This function returns a poison variate with mean dLambda.
static java.math.BigDecimal getUniform(java.math.BigDecimal a, java.math.BigDecimal b)
          This function returns a continuous uniform variate between a and b.
static double getUniform(double dA, double dB)
          This function returns a continuous uniform variate between dA and dB.
static int getUniform(int nA, int nB)
          This function returns a discrete uniform variate between nA and nB.
static long getUniform(long a, long b)
          This function returns a discrete uniform variate between a and b.
static boolean getUniformBoolean()
          Returns the next pseudorandom, uniformly distributed boolean value.
static double getUniformDouble()
          Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 (exclusive).
static void setRandomSeed(long seed)
          Sets the seed of this random number generator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBernoulli

public static final int getBernoulli(double dP)
This function returns a bernoulli variate with a probability P of success.

Parameters:
dP - The probability of success.
Returns:
a bernoulli variate with probability dP of success.

getBinomial

public static final int getBinomial(double dP,
                                    int nT)
This function returns a binomial variate of T bernoulli trails with probability P of success.

Parameters:
dP - The probability of success.
Returns:
a binomial variate with probability dP of success.

getExponential

public static final double getExponential(double dMu)
This function returns an exponential variate with mean 1/dMu.

Parameters:
dMu - The value 1/dMu is the mean of the exponential variate.
Returns:
an exponential variate with mean 1/dMu.

getNormal

public static final double getNormal(double dMean,
                                     double dStdDev)
This function returns an approximate normal variate with the specified mean and standard deviation.

Parameters:
dMean - The mean of the normal variate.
dStdDev - The standard deviation of the normal variate.
Returns:
a normal variate.

getNormalDouble

public static final double getNormalDouble()
Returns the next pseudorandom, Gaussian ("normally") distributed double value between 0.0 and 1.0 (exclusive).

Returns:
a continuous normal variate between 0 and 1.0 (exclusive).

getPoison

public static final int getPoison(double dLambda)
This function returns a poison variate with mean dLambda.

Parameters:
dLambda - The mean of the poison variate.
Returns:
a poison variate with mean dLambda.

getUniform

public static final java.math.BigDecimal getUniform(java.math.BigDecimal a,
                                                    java.math.BigDecimal b)
This function returns a continuous uniform variate between a and b. This method should be used when arbitrary precision values are required.

Parameters:
a - The minimum value of the variate.
b - The maxinum value of the variate.
Returns:
a continuous uniform variate between a and b.

getUniform

public static final double getUniform(double dA,
                                      double dB)
This function returns a continuous uniform variate between dA and dB. Due to rounding errors, this method should only be used for "smaller" values of dA and dB that is not too close to Double.MIN_VALUE and Double.MAX_VALUE. Doing so may result in unexpected return values.

Parameters:
dA - The minimum value of the variate.
dB - The maxinum value of the variate.
Returns:
a continuous uniform variate between dA and dB.

getUniform

public static final int getUniform(int nA,
                                   int nB)
This function returns a discrete uniform variate between nA and nB. Due to rounding errors, this method should only be used for "smaller" values of a and b that is not too close to Integer.MIN_VALUE and Integer.MAX_VALUE. Doing so may result in unexpected return values.

Parameters:
nA - The minimum value of the variate.
nB - The maxinum value of the variate.
Returns:
a discrete uniform variate between nA and nB.

getUniform

public static final long getUniform(long a,
                                    long b)
This function returns a discrete uniform variate between a and b. Due to rounding errors, this method should only be used for "smaller" values of a and b that is not too close to Long.MIN_VALUE and Long.MAX_VALUE. Doing so may result in unexpected return values.

Parameters:
a - The minimum value of the variate.
b - The maxinum value of the variate.
Returns:
a discrete uniform variate between a and b.

getUniformBoolean

public static final boolean getUniformBoolean()
Returns the next pseudorandom, uniformly distributed boolean value.

Returns:
a uniform boolean variate.

getUniformDouble

public static final double getUniformDouble()
Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 (exclusive).

Returns:
a continuous uniform variate between 0 and 1.0 (exclusive).

setRandomSeed

public static final void setRandomSeed(long seed)
Sets the seed of this random number generator.


ThinkUI Data Generator 1.0.2 API

Copyright © 2007-2009. ThinkUI Software Inc. All rights reserved.