lot Class Reference

Provides a series of random number generators. More...

#include <lot.h>

List of all members.

Public Types

enum  { RAN_POL = 1, RAN_KNU, RAN_MT }
enum  { PRECISE = 100, FAST }
enum  { OPEN = 1000, ZERO, ZERO_ONE }

Public Member Functions

 lot (int type=RAN_MT, int gType=ZERO)
 ~lot (void)
void set_generator (int type, int gType)
long seed (void)
long init_seed (void)
void randomize (int spin=100)
void set_seed (long s)
void dememorize (int spin=100)
void ran_start (long seed)
void ranf_start (long seed)
int random_int (int)
long random_long (long maxval=Util::int_max)
long ran_knu (void)
double uniform (void)
void ran_array (std::vector< long > &x, int n)
void ranf_array (std::vector< double > &aa, int n)
void MT_sgenrand (long seed)
void MT_init_by_array (unsigned long *init_key, int key_length)
void MT_R_initialize (int seed)
unsigned long MT_genrand_int (void)
double MT_genrand (void)
double MT_genrand_with_zero (void)
double MT_genrand_with_zero_one (void)
bool Set_MT (int type)
double beta (double aa, double bb)
int binom (double nin, double pp)
double cauchy (double l, double s)
double chisq (double n)
std::vector< double > dirichlet (std::vector< double > c)
double expon (void)
double exponential (const double lambda)
double f (double m, double n)
double gamma (double a, double scale=1.0)
double geom (double p)
int hypergeom (int nn1, int nn2, int kk)
double igamma (const double a, const double s=1.0)
double lnorm (double logmean, double logsd)
double logis (double location, double scale)
std::vector< int > multinom (unsigned n, const std::vector< double > &p)
double nbinom (double n, double p)
int poisson (double mu)
double norm (const double mu, const double sd)
double snorm (void)
double t (double df)
double weibull (double shape, double scale)
double get_ran_u_0 (void) const


Detailed Description

Provides a series of random number generators.

This class provides a series of random number generators. Three different uniform random number generators are provided. By default the Mersenne twister is used. Sources are acknowledged in the source code by including copyright information (where appropriate).

It is given the name "lot" because the noun lot is defined as "an object used in deciding something by chance" according to The New Merriam-Webster Dictionary,

To seed the random number generator with a specific value (useful for debugging stochastic simulations), do the following:

     lot rng;
     rng.set_seed(1234L);

You can, of course pick any number you like.

Definition at line 67 of file lot.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
RAN_POL  Paul's original RNG from J. Monahan, NCSU.
RAN_KNU  Knuth's rng.c translated to C++.
RAN_MT  Mersenne twister MT19937.

Definition at line 69 of file lot.h.

anonymous enum

Enumerator:
PRECISE  use double version of uniform with RAN_KNU
FAST  retrieve double from uniform long with RAN_KNU

Definition at line 75 of file lot.h.

anonymous enum

Enumerator:
OPEN  uniform on (0,1) with RAN_MT
ZERO  uniform on [0,1) with RAN_MT
ZERO_ONE  uniform on [0,1] with RAN_MT

Definition at line 80 of file lot.h.


Constructor & Destructor Documentation

lot::lot ( int  type = RAN_MT,
int  gType = ZERO 
)

Default constructor

Uses Mersenne twister on [0,1) by default and selects integer implementation of Knuth generator by default, using long -> double conversion for uniform on [0,1) instead of direct calculations with floating point

Parameters:
type RAN_POL (Lewis), RAN_KNU (Knuth), RAN_MT (Mersenne Twister)
gType RAN_KNU: PRECISE (floating point), FAST (long -> double) FAST is default because PRECISE != WITH_ZERO RAN_MT: OPEN (0,1), WITH_ZERO [0,1), ZERO_ONE [0,1]

Definition at line 236 of file lot.cpp.

References set_generator().

lot::~lot ( void   ) 

Destructor

Currently empty. Nothing to clean up

Definition at line 250 of file lot.cpp.


Member Function Documentation

void lot::set_generator ( int  type,
int  gType 
)

Set uniform RNG type

Parameters:
type RAN_POL, RAN_KNU, or RAN_MT
gType PRECISE or FAST (RAN_KNU) DEFAULT, WITH_ZERO, or ZERO_ONE (RAN_MT)

Definition at line 259 of file lot.cpp.

References MT_genrand(), MT_sgenrand(), PRECISE, RAN_KNU, RAN_MT, RAN_POL, ran_start(), randomize(), ranf_start(), and Set_MT().

Referenced by lot().

long lot::seed ( void   )  [inline]

First seed from RAN_POL

Definition at line 92 of file lot.h.

long lot::init_seed ( void   )  [inline]

Second seed from RAN_POL

Definition at line 98 of file lot.h.

void lot::randomize ( int  spin = 100  ) 

Initializes RAN_POL

Parameters:
spin (default 100) passed to dememorize()
Initializes seeds with current system time and calls dememorize to "warm up" random number generator

Definition at line 317 of file lot.cpp.

References dememorize().

Referenced by set_generator().

void lot::set_seed ( long  s  ) 

Initialize RNG with known seed

Parameters:
s Seed

Definition at line 328 of file lot.cpp.

References MT_sgenrand(), RAN_KNU, RAN_MT, RAN_POL, ran_start(), and ranf_start().

void lot::dememorize ( int  spin = 100  ) 

Used with RAN_POL to "warm up" generator

Parameters:
spin number of preliminary calls to uniform()

Definition at line 304 of file lot.cpp.

References uniform().

Referenced by randomize().

void lot::ran_start ( long  seed  ) 

Initialize the Knuth long RNG

Definition at line 567 of file lot.cpp.

References ran_array(), and t().

Referenced by set_generator(), and set_seed().

void lot::ranf_start ( long  seed  ) 

Initialize the Knuth double RNG

Definition at line 443 of file lot.cpp.

References ranf_array(), and t().

Referenced by set_generator(), and set_seed().

int lot::random_int ( int  maxval  ) 

Returns a random int in [0,maxval-1]

Parameters:
maxval 

Definition at line 878 of file lot.cpp.

References uniform().

long lot::random_long ( long  maxval = Util::int_max  ) 

Returns a random long in [0,maxval-1]

Parameters:
maxval 

Definition at line 863 of file lot.cpp.

References uniform().

long lot::ran_knu ( void   )  [inline]

Uniform random integer in [0, Util::int_max-1] with RAN_KNU

Definition at line 115 of file lot.h.

double lot::uniform ( void   )  [inline]

Uniform random number

RAN_POL & RAN_KNU produce uniform on [0,1) RAN_MT produces uniform on [0,1) by default RAN_MT can produce uniform on (0,1) or [0,1]

See also:
Set_MT

Definition at line 126 of file lot.h.

Referenced by dememorize(), expon(), random_int(), and random_long().

void lot::ran_array ( std::vector< long > &  aa,
int  n 
)

Updates long array of Knuth generator

Parameters:
aa the vector of values in which to update
n the number of values to update, note n == aa.size() assumed

Definition at line 534 of file lot.cpp.

Referenced by ran_start().

void lot::ranf_array ( std::vector< double > &  aa,
int  n 
)

Updates floating point array of Knuth generator

Parameters:
aa the vector of values in which to update
n the number of values to update, note n == aa.size() assumed

Definition at line 410 of file lot.cpp.

Referenced by ranf_start().

void lot::MT_sgenrand ( long  seed  ) 

Initializes Mersenne twister RNG

Parameters:
seed 
This code is translated directly from:

http://www.math.keio.ac.jp/matumoto/CODES/MT2002/mt19937ar.c

Here are the accompanying comments

A C-program for MT19937, with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto.

Before using, initialize the state by using init_genrand(seed) or init_by_array(init_key, key_length).

Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Any feedback is very welcome. http://www.math.keio.ac.jp/matumoto/emt.html email: matumoto@math.keio.ac.jp

Definition at line 725 of file lot.cpp.

Referenced by MT_genrand_int(), MT_init_by_array(), set_generator(), and set_seed().

void lot::MT_init_by_array ( unsigned long *  init_key,
int  key_length 
)

Initialize Mersenne twister with an array

Parameters:
init_key is the array for initializing keys
key_length is its length

Definition at line 745 of file lot.cpp.

References MT_sgenrand().

void lot::MT_R_initialize ( int  seed  ) 

Initialize array directly with algorithm from R

Parameters:
seed Probably useful only for testing purposes. I wrote it to allow me to check norm(), binom(), beta(), etc. against R. It only produces the same sequence as R when seed == 1.

Definition at line 787 of file lot.cpp.

unsigned long lot::MT_genrand_int ( void   ) 

generate random integer on [0,0xffffffff]-interval

Definition at line 800 of file lot.cpp.

References MT_sgenrand().

Referenced by MT_genrand(), MT_genrand_with_zero(), and MT_genrand_with_zero_one().

double lot::MT_genrand ( void   ) 

generate random double uniform on (0,1)

Definition at line 839 of file lot.cpp.

References MT_genrand_int().

Referenced by set_generator(), and Set_MT().

double lot::MT_genrand_with_zero ( void   ) 

generate random double uniform on [0,1)

Definition at line 846 of file lot.cpp.

References MT_genrand_int().

Referenced by Set_MT().

double lot::MT_genrand_with_zero_one ( void   ) 

generate random double uniform on [0,1]

Definition at line 853 of file lot.cpp.

References MT_genrand_int().

Referenced by Set_MT().

bool lot::Set_MT ( int  type  ) 

Set MT type

Parameters:
type DEFAULT (0,1), ZERO [0,1), ZERO_ONE [0,1]
Leaves MT type unchanged if type is not one of DEFAULT, ZERO, or ZERO_ONE. Changes from RAN_POL or RAN_KNU to RAN_MT.

Definition at line 354 of file lot.cpp.

References MT_genrand(), MT_genrand_with_zero(), MT_genrand_with_zero_one(), OPEN, RAN_MT, ZERO, and ZERO_ONE.

Referenced by set_generator().

double lot::beta ( double  aa,
double  bb 
)

Returns a random beta variate

\[f(x) = \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}x^{a-1}(1-x)^{b-1} \]

Parameters:
aa The first beta parameter ($a$)
bb The second beta parameter ($b$)
Returns a random variable from a beta distribution with parameters aa and bb.

NOTE: Checks for aa, bb > 0 not included

NOTE: R uses RNGs uniform on [0,1). To ensure consistency with that well tested code make sure that you have Set_MT(ZERO), or the equivalent, if you are using the Mersenne-Twister. ZERO is the default.

This implementation is derived from R v1.9.0

Definition at line 938 of file lot.cpp.

References gamma(), t(), and unif_rand.

Referenced by proposeBeta().

int lot::binom ( double  nin,
double  pp 
)

Returns a random binomial variate

\[ f(x) = {n \choose k}p^k(1-p)^{n-k} \]

Parameters:
nin sample size ($n$)
pp probability of success on each trial ($p$)

\[ \mbox{E}(x) = np \]

\[ \mbox{Var}(x) = np(1-p) \]

This implementation is derived from R v1.9.0.

NOTE: Checks for finite nin and pp not included. Check for nin == floor(n+0.5) not included

Definition at line 1070 of file lot.cpp.

References f(), repeat, and unif_rand.

Referenced by multinom().

double lot::cauchy ( double  l,
double  s 
)

Returns a Cauchy variate

\[ f(x) = \frac{1}{\pi\mbox{s} (1 + (\frac{x-\mbox{l}}{\mbox{s}})^2)} \]

Parameters:
l the location parameter
s the scale parameter
The expectation and variance of the Cauchy distribution are infinite. The mode is equal to the location parameter.

Modified from R v2.0. Does not check isnan() on arguments. Does not check that arguments are finite

Definition at line 1252 of file lot.cpp.

References unif_rand.

double lot::chisq ( double  n  ) 

Returns a chi-squared variate

\[ f(x) = \frac{1}{2^{n/2}\Gamma(n/2)}x^{n/2-1}e^{-x/2} \]

Parameters:
n degrees of freedom for the chi-squared density

\[ \mbox{E}(x) = \mbox{n} \]

\[ \mbox{Var}(x) = 2\mbox{n} \]

Derived from R v2.0. Does not check isfinite() on argument.

Definition at line 1298 of file lot.cpp.

References gamma().

Referenced by f(), and t().

std::vector< double > lot::dirichlet ( std::vector< double >  c  ) 

Returns a vector of Dirichlet variates

\[ f({\bf x}) = \frac{\Gamma(\sum_i x_i)}{\prod_i\Gamma(x_i)}\prod_ix_i^{c_i} \]

Parameters:
c [vector<double>] parameters of the Dirichlet

Definition at line 1310 of file lot.cpp.

References gamma().

Referenced by proposeDirch().

double lot::expon ( void   ) 

Returns a random value from an exponential distribution with mean 1.

\[ f(x) = e^{-1} \]

\[ \mbox{E}(x) = 1 \]

\[ \mbox{Var}(x) = 1 \]

originally derived from R v1.8.1

NOTE: R uses RNGs uniform on [0,1). To ensure consistency with that well tested code make sure that you have Set_MT(ZERO), or the equivalent, if you are using the Mersenne-Twister. ZERO is the default.

Definition at line 1384 of file lot.cpp.

References uniform().

Referenced by exponential().

double lot::exponential ( const double  lambda  )  [inline]

Exponential random deviate

Parameters:
lambda The exponential parameter ($\lambda$)

\[ f(x) = \lambda e^{-\lambda x} \]

\[ \mu = \frac{1}{\lambda} \]

\[ \sigma^2 = \left(\frac{1}{\lambda}\right)^2 \]

Calls expon() to do the real work

Definition at line 162 of file lot.h.

References expon().

double lot::f ( double  m,
double  n 
)

Returns an F variate

\[ f(x) = \frac{\Gamma((m+n)/2)}{\Gamma(m/2)\Gamma(n/2)}(m/n)^{m/2}x^{m/2-1}(1+(m/n)x)^{-(m+n)/2} \]

Parameters:
m ``numerator'' degrees of freedom
n ``denominator'' degrees of freedom

\[ \mbox{E}(x) = \frac{m}{m-2}, m > 2 \]

\[ \mbox{Var}(x) = \frac{2m^2(n-2)}{n(m+2)}, n > 2 \]

Derived from R v2.0. Does not check arguments for isnan() or isfinite().

Definition at line 1480 of file lot.cpp.

References chisq().

Referenced by binom(), and hypergeom().

double lot::gamma ( double  a,
double  scale = 1.0 
)

Gamma random deviate

Parameters:
a Shape
scale Scale ($\sigma$, defaults to 1.0)

\[ f(x) = \frac{1}{\sigma^a \Gamma(a)}x^{a-1}e^{-x/\sigma} \]

\[ \mu = a\sigma \]

\[ \sigma^2 = a\sigma^2 \]

NOTE: Checks for finite scale and shape parameters not included

NOTE: R uses RNGs uniform on [0,1). To ensure consistency with that well tested code make sure that you have Set_MT(ZERO), or the equivalent, if you are using the Mersenne-Twister. ZERO is the default.

Derived from R v1.9.0

Definition at line 1551 of file lot.cpp.

References exp_rand, norm_rand, repeat, t(), and unif_rand.

Referenced by beta(), chisq(), dirichlet(), igamma(), and nbinom().

double lot::geom ( double  p  ) 

Returns a geometric deviate

\[ f(x) = p(1-p)^x \]

Parameters:
p the parameter of the geometric distribution

\[ \mbox{E}(x) = \frac{1-p}{p} \]

\[ \mbox{Var}(x) = \frac{1-p}{p^2} \]

Derived from R v2.0. Does not check isnan() on x and p. Does not check for 0 < p < 1.

Definition at line 1754 of file lot.cpp.

References exp_rand, and poisson().

int lot::hypergeom ( int  nn1,
int  nn2,
int  kk 
)

Returns a hypergeometric variate

\[ f(x) = \frac{{w \choose x}{b \choose n-x}}{{w+b \choose n}} \]

Parameters:
nn1 The number of white balls in the urn ($w$)
nn2 The number of black balls in the urn ($b$)
kk The sample size ($n$)

\[ \mbox{E}(x) = n(\frac{w}{w+b}) \]

\[ \mbox{Var}(x) = \frac{n(\frac{w}{w+b})(1-\frac{w}{w+b})((w+b)-n)}{w+b-1} \]

The code is modified from R v2.0 to take unsigned integer arguments rather than doubles. isfinite() checks are no longer needed. Check for n < r + b not done.

Definition at line 1812 of file lot.cpp.

References Density::dt(), f(), t(), and unif_rand.

double lot::igamma ( const double  a,
const double  s = 1.0 
) [inline]

Inverse gamma random deviate

\[ f(1/x) = \frac{1}{s^a \Gamma(a)}x^{a-1}e^{-x/s} \]

or equivalently

\[ f(y) = \frac{\lambda^a (1/y)^{a+1} e^{-\lambda/y}}{\Gamma(a)} \]

\[ \lambda = 1/s \]

Parameters:
a Shape ($a$)
s Scale ($s$)

\[ \mbox{E}(x) = \frac{\lambda}{a-1} \quad , \quad a > 1 \]

\[ \mbox{Var}(x) = \frac{\lambda^2}{(a-1)^2(a-2)} \quad , \quad a > 2 \]

Definition at line 184 of file lot.h.

References gamma().

double lot::lnorm ( double  logmean,
double  logsd 
)

Returns a log-normal deviate

\[ f(x) = \frac{1}{\sigma x\sqrt{2\pi}}e^{-\frac{(\log(x) - \mu)^2}{2\sigma^2}} \]

Parameters:
logmean logarithm of the mean of the corresponding normal ($\mu$)
logsd logarithm of the sd of the corresponding normal ($\sigma$)

\[ \mbox{E}(x) = e^{\mu + \sigma^2/2} \]

\[ \mbox{Var}(x) = e^{2\mu + \sigma^2}(e^{\sigma^2}-1) \]

\[ \mbox{mode} = \frac{e^\mu}{e^{\sigma^2}} \]

\[ \mbox{median} = e^\mu \]

Derived from R v2.0. Does not do isnan() checks on arguments. Does not check for sigma > 0.

Definition at line 2093 of file lot.cpp.

References norm().

double lot::logis ( double  location,
double  scale 
)

Returns a logistic variate

\[ f(x) = \frac{1}{s}\frac{e^{\frac{x-m}{s}}}{(1 + e^{\frac{x-m}{s}})^2} \]

or equivalently (dividing numerator and denominator by $e^{2\frac{x-m}{s}}$)

\[ f(x) = \frac{1}{s}\frac{e^{\frac{-(x-m)}{s}}}{(1 + e^{\frac{-(x-m)}{s}})^2} \]

Parameters:
location the location parameter ($m$)
scale the scale parameter ($s$)

\[ \mbox{E}(x) = m \]

\[ \mbox{Var}(x) = \frac{\pi^2s^2}{3} \]

Derived from R v2.0. Does not do isnan() checks on parameters. Does not check for scale > 0.

Definition at line 2133 of file lot.cpp.

std::vector< int > lot::multinom ( unsigned  n,
const std::vector< double > &  p 
)

\[ f({\bf n}) = {\sum_i n_i \choose n_1 \dots n_I}\prod_i p_i^{n_i} \]

Parameters:
n Sample size ($\sum_i n_i$)
p Vector of probabilities ($p_i$)
Derived from R v2.0. Safety checks eliminated. User must ensure that $\sum_i p_i = 1$ and $p_i >= 0$. $n > 0$ guaranteed, because $n$ is unsigned.

Definition at line 2183 of file lot.cpp.

References binom().

double lot::nbinom ( double  n,
double  p 
)

Returns a negative binomial variate

\[ f(x) = \frac{\Gamma(x+n)}{\Gamma(n)x!}p^n(1-p)^x \]

Parameters:
n the ``size'' parameter
p the ``probability'' parameter

\[ \mbox{E}(x) = \frac{x(1-p)}{p} \]

\[ \mbox{Var}(x) = \frac{x(1-p)}{p^2} \]

Derived from R v2.0. Does not check isfinite() on arguments or ensure that p is in [0, 1).

Definition at line 2270 of file lot.cpp.

References gamma(), and poisson().

int lot::poisson ( double  mu  ) 

Returns Poisson deviate

\[ f(x) = \frac{\lambda^x e^{-\lambda}}{x!} \]

Parameters:
mu mean of the Poisson distribution ($\lambda$)

\[ \mbox{E}(x) = \mu \]

\[ \mbox{Var}(x) = \mu \]

derived from R v1.9.0

NOTE: Check for finite mu not included

NOTE: R uses RNGs uniform on [0,1). To ensure consistency with that well tested code make sure that you have Set_MT(ZERO), or the equivalent, if you are using the Mersenne-Twister. ZERO is the default.

Definition at line 2324 of file lot.cpp.

References exp_rand, norm_rand, repeat, t(), and unif_rand.

Referenced by geom(), and nbinom().

double lot::norm ( const double  mu,
const double  sd 
) [inline]

Normal random deviate

\[ f(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} \]

Parameters:
mu Mean ($\mu$)
sd Standard deviation ($\sigma$)

\[ \mbox{E}(x) = \mu \]

\[ \mbox{Var}(x) = \sigma^2 \]

Calls snorm() to do the real work.

Definition at line 204 of file lot.h.

References snorm().

Referenced by lnorm(), and proposeNorm().

double lot::snorm ( void   ) 

Returns standard normal deviate

\[ f(x) = \frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}} \]

Kinderman-Ramage standard normal generator from R v1.9.0

\[ \mbox{E}(x) = 0 \]

\[ \mbox{Var}(x) = 1 \]

NOTE: R uses RNGs uniform on [0,1). To ensure consistency with that well tested code make sure that you have Set_MT(ZERO), or the equivalent, if you are using the Mersenne-Twister. ZERO is the default.

Definition at line 2506 of file lot.cpp.

References repeat, and unif_rand.

Referenced by norm().

double lot::t ( double  df  ) 

Returns a t variate

\[ f(x) = \frac{\Gamma(\frac{\nu+1}{2})}{\sqrt{\pi\nu}\Gamma(\frac{\nu}{2})(1 + \frac{x^2}{\nu})^{(\nu + 1)/2}} \]

Parameters:
df the degrees of freedom ($\nu$)

\[ \mbox{E}(x) = 0 \quad , \quad \nu > 1 \]

\[ \mbox{Var}(x) = \frac{\nu}{\nu - 2} \quad , \quad \nu > 2 \]

Derived from R v2.0. Does not check isnan() or isfinite() on argument.

Definition at line 2594 of file lot.cpp.

References chisq(), and norm_rand.

Referenced by beta(), gamma(), hypergeom(), poisson(), ran_start(), and ranf_start().

double lot::weibull ( double  shape,
double  scale 
)

Returns a Weibull variate

\[ f(x) = (\frac{a}{b})(\frac{x}{b})^{a-1}e^{-\frac{x}{b}^a} \]

Parameters:
shape the ``shape'' parameter ($a$)
scale the ``scale'' parameter ($b$)

\[ \mbox{E}(x) = b\Gamma(1 + \frac{1}{a}) \]

\[ \mbox{Var}(x) = b^2(\Gamma(1+\frac{2}{a}) - \Gamma(1+\frac{1}{a})^2) \]

Derived from R v2.0. Does not check isnan() on arguments. Does not check for $a > 0$ and $b > 0$.

Definition at line 2638 of file lot.cpp.

References unif_rand.

double lot::get_ran_u_0 ( void   )  const [inline]

First element of internal array in RAN_KNU

Public only to allow testing of PRECISE

Definition at line 215 of file lot.h.


The documentation for this class was generated from the following files:
Generated on Tue Mar 27 16:03:49 2007 for mcmc by  doxygen 1.5.1