class RND




Public


Features
beta(a,b:INT):FLTD .. Included as beta
**** Samples from the Beta distribution `p(x)=(G(a+b)/(G(a)G(b)))x^(a-1)(1-x)^(b-1)', `0<x<1', `a,b>0'. Mean is `a/(a+b)'. Knuth, Vol. 2, p. 129.
binomial(n:INT, p:FLTD):INT .. Included as binomial
**** Samples from the binomial distribution: `P(t)=(n t) p^t (1-p)^(n-t)'. Mean is `np'. Is number of occurrences of a probability `p' event in `n' trials. Based on Knuth, Vol. 2, p. 131. and Numerical Recipes in C, p. 223.
bit(p:FLTD):BOOL .. Included as bit
**** True with probability `p'.
cantor(s:FLTD):FLTD .. Included as cantor
**** A uniform random sample from a Cantor set with scaling `s'.
cauchy:FLTD .. Included as cauchy
**** Samples from the Cauchy distribution: `p(x)=1/pi(1+x^2)'. (Also called the Lorentzian.) No mean. Based on NR in C. p. 220.
chi_square(v:INT):FLTD .. Included as chi_square
**** Samples from the Chi-Square distribution: `p(x)=e^(-x/2)x^((v/2)-1)/(2^(v/2)G(v/2))'. Mean is `v'. `x>=0'. Based on Knuth, Vol. 2, p. 130.
create: SAME .. Included as create
**** Creates a new stream of random values.
exponential(m:FLTD):FLTD .. Included as exponential
**** Samples from an exponential distribution: `p(x)=e^(-x/m)/m'. Mean is `m'. Eg: Time between emissions when one per `m' seconds on average. Based on Knuth, Vol. 2, p. 128.
f_dist(v1,v2:INT):FLTD .. Included as f_dist
**** Samples from the F-distribution with `v1' and `v2' degrees of freedom (see any statistics text). Based on Knuth, Vol. 2, p. 130.
gamma(a:FLTD):FLTD .. Included as gamma
**** Samples from the Gamma distribution: `p(x)=(x^(a-1)e^(-x))/G(a)'. Mean is `a>0'. Uses Cheng's algorithm from Devroye, "Non-Uniform Random Variate Generation", Springer-Verlag, (1986) p. 413. This is much less restrictive than the Numerical Recipes algorithm.
gen: GEN .. Included as gen
****
__Interface_to_the_generator._If_self_is_void,_use_the_shared
generator, otherwise use the created generator
geometric(p:FLTD):INT .. Included as geometric
**** Samples from the geometric distribution. Is the number of trials needed until an event of probability `p' first occurs. `P(n)=(1-p)^(n-1)p'. Mean is `1/p'. Based on Knuth, Vol. 2, p. 131.
int(l,u:INT):INT .. Included as int
**** A uniform random member of `{l,...,u}'.
poisson(x:FLTD):INT .. Included as poisson
**** Samples from the Poisson distribution: `p(j)=x^j e^(-x)/j!'. Mean is `x'. Is number of events in time interval `x'. Based on Numerical Recipes in C, p. 221.
seed(seed: INT) .. Included as seed
**** Initialize the generator with "seed" Can use with assignment notation
standard_cantor:FLTD .. Included as standard_cantor
**** A uniform random sample from the canonical Cantor set in `[0,1)'.
standard_normal:FLTD .. Included as standard_normal
**** A normally distributed `FLTD' with mean `0.' and unit variance. Uses Box-Muller method which generates two normal deviates and requires two calls to uniform. One of these is cached for the next call. Based on Knuth, Vol. 2, p. 117.
t_dist(v:INT):FLTD .. Included as t_dist
**** Samples from the t-distribution with `v' degrees of freedom (see any statistics text). Based on Knuth, Vol. 2, p. 130.
uniform: FLTD .. Included as uniform
**** A uniformly distributed double in `[0.,1.)'.
uniform_range(l,u: FLTD): FLTD .. Included as uniform_range
**** A uniformly distributed double in the range `[l,u)'.


Private

shared default_gen: GEN; .. Included as default_gen
**** Shared generator
shared default_gen: GEN; .. Included as default_gen
**** Shared generator
make_generator: GEN .. Included as make_generator
**** Since $RANDOM_GEN::create returns a $RANDOM_GEN, we have to typecase to make sure that it actually is of type GEN (abstract classes cannot return SAME)
attr norm_cache:FLTD; .. Included as norm_cache
**** Cache of normal deviate generated earlier.
attr norm_cache:FLTD; .. Included as norm_cache
**** Cache of normal deviate generated earlier.
attr norm_cache_valid:BOOL; .. Included as norm_cache_valid
**** `True' if a value is cached.
attr norm_cache_valid:BOOL; .. Included as norm_cache_valid
**** `True' if a value is cached.
attr own_gen: GEN; .. Included as own_gen
**** Individualized generator
attr own_gen: GEN; .. Included as own_gen
**** Individualized generator
shared snorm_cache:FLTD; .. Included as snorm_cache
**** Shared version of above.
shared snorm_cache:FLTD; .. Included as snorm_cache
**** Shared version of above.
shared snorm_cache_valid:BOOL; .. Included as snorm_cache_valid
**** Shared version of above.
shared snorm_cache_valid:BOOL; .. Included as snorm_cache_valid
**** Shared version of above.

The Sather Home Page