Scythe-1.0.3
Public Member Functions | Protected Member Functions | Protected Attributes
scythe::rng< RNGTYPE > Class Template Reference

Random number generator. More...

#include <scythestat/rng.h>

List of all members.

Public Member Functions

double operator() ()
 Generate uniformly distributed random variates.
double runif ()
 Generate uniformly distributed random variates.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > runif (unsigned int rows, unsigned int cols)
Matrix< double, Col, Concrete > runif (unsigned int rows, unsigned int cols)
double rbeta (double alpha, double beta)
 Generate a beta distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rbeta (unsigned int rows, unsigned int cols, double alpha, double beta)
Matrix< double, Col, Concrete > rbeta (unsigned int rows, unsigned int cols, double alpha, double beta)
double rnchypgeom (double m1, double n1, double n2, double psi, double delta)
 Generate a non-central hypergeometric disributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rnchypgeom (unsigned int rows, unsigned int cols, double m1, double n1, double n2, double psi, double delta)
Matrix< double, Col, Concrete > rnchypgeom (unsigned int rows, unsigned int cols, double m1, double n1, double n2, double psi, double delta)
unsigned int rbern (double p)
 Generate a Bernoulli distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< unsigned int, O, S > rbern (unsigned int rows, unsigned int cols, double p)
Matrix< unsigned int, Col,
Concrete > 
rbern (unsigned int rows, unsigned int cols, double p)
unsigned int rbinom (unsigned int n, double p)
 Generate a binomial distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< unsigned int, O, S > rbinom (unsigned int rows, unsigned int cols, unsigned int n, double p)
Matrix< unsigned int, Col,
Concrete > 
rbinom (unsigned int rows, unsigned int cols, unsigned int n, double p)
double rchisq (double df)
 Generate a $\chi^2$ distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rchisq (unsigned int rows, unsigned int cols, double df)
Matrix< double, Col, Concrete > rchisq (unsigned int rows, unsigned int cols, double df)
double rexp (double invscale)
 Generate an exponentially distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rexp (unsigned int rows, unsigned int cols, double invscale)
Matrix< double, Col, Concrete > rexp (unsigned int rows, unsigned int cols, double invscale)
double rf (double df1, double df2)
 Generate an F distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rf (unsigned int rows, unsigned int cols, double df1, double df2)
Matrix< double, Col, Concrete > rf (unsigned int rows, unsigned int cols, double df1, double df2)
double rgamma (double shape, double rate)
 Generate a gamma distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rgamma (unsigned int rows, unsigned int cols, double shape, double rate)
Matrix< double, Col, Concrete > rgamma (unsigned int rows, unsigned int cols, double shape, double rate)
double rlogis (double location, double scale)
 Generate a logistically distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rlogis (unsigned int rows, unsigned int cols, double location, double scale)
Matrix< double, Col, Concrete > rlogis (unsigned int rows, unsigned int cols, double location, double scale)
double rlnorm (double logmean, double logsd)
 Generate a log-normal distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rlnorm (unsigned int rows, unsigned int cols, double logmean, double logsd)
Matrix< double, Col, Concrete > rlnorm (unsigned int rows, unsigned int cols, double logmean, double logsd)
unsigned int rnbinom (double n, double p)
 Generate a negative binomial distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< unsigned int, O, S > rnbinom (unsigned int rows, unsigned int cols, double n, double p)
Matrix< unsigned int, Col,
Concrete > 
rnbinom (unsigned int rows, unsigned int cols, double n, double p)
double rnorm (double mean=0, double sd=1)
 Generate a normally distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rnorm (unsigned int rows, unsigned int cols, double mean, double sd)
Matrix< double, Col, Concrete > rnorm (unsigned int rows, unsigned int cols, double mean, double sd)
unsigned int rpois (double lambda)
 Generate a Poisson distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< unsigned int, O, S > rpois (unsigned int rows, unsigned int cols, double lambda)
Matrix< unsigned int, Col,
Concrete > 
rpois (unsigned int rows, unsigned int cols, double lambda)
double rt (double mu, double sigma2, double nu)
 Generate a Student t distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rt1 (unsigned int rows, unsigned int cols, double mu, double sigma2, double nu)
Matrix< double, Col, Concrete > rt1 (unsigned int rows, unsigned int cols, double mu, double sigma2, double nu)
double rweibull (double shape, double scale)
 Generate a Weibull distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rweibull (unsigned int rows, unsigned int cols, double shape, double scale)
Matrix< double, Col, Concrete > rweibull (unsigned int rows, unsigned int cols, double shape, double scale)
double richisq (double nu)
 Generate an inverse $\chi^2$ distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > richisq (unsigned int rows, unsigned int cols, double nu)
Matrix< double, Col, Concrete > richisq (unsigned int rows, unsigned int cols, double nu)
double rigamma (double alpha, double beta)
 Generate an inverse gamma distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rigamma (unsigned int rows, unsigned int cols, double alpha, double beta)
Matrix< double, Col, Concrete > rigamma (unsigned int rows, unsigned int cols, double alpha, double beta)
double rtnorm (double mean, double variance, double below, double above)
 Generate a truncated normally distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rtnorm (unsigned int rows, unsigned int cols, double mean, double variance, double above, double below)
Matrix< double, Col, Concrete > rtnorm (unsigned int rows, unsigned int cols, double mean, double variance, double above, double below)
double rtnorm_combo (double mean, double variance, double below, double above)
 Generate a truncated normally distributed random variate.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rtnorm_combo (unsigned int rows, unsigned int cols, double mean, double variance, double above, double below)
Matrix< double, Col, Concrete > rtnorm_combo (unsigned int rows, unsigned int cols, double mean, double variance, double above, double below)
double rtbnorm_slice (double mean, double variance, double below, unsigned int iter=10)
 Generate a normally distributed random variate, truncated below.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rtbnorm_slice (unsigned int rows, unsigned int cols, double mean, double variance, double below, unsigned int iter=10)
Matrix< double, Col, Concrete > rtbnorm_slice (unsigned int rows, unsigned int cols, double mean, double variance, double below, unsigned int iter=10)
double rtanorm_slice (double mean, double variance, double above, unsigned int iter=10)
 Generate a normally distributed random variate, truncated above.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rtanorm_slice (unsigned int rows, unsigned int cols, double mean, double variance, double above, unsigned int iter=10)
Matrix< double, Col, Concrete > rtanorm_slice (unsigned int rows, unsigned int cols, double mean, double variance, double above, unsigned int iter=10)
double rtbnorm_combo (double mean, double variance, double below, unsigned int iter=10)
 Generate a normally distributed random variate, truncated below.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rtbnorm_combo (unsigned int rows, unsigned int cols, double mean, double variance, double below, unsigned int iter=10)
Matrix< double, Col, Concrete > rtbnorm_combo (unsigned int rows, unsigned int cols, double mean, double variance, double below, unsigned int iter=10)
double rtanorm_combo (double mean, double variance, double above, const unsigned int iter=10)
 Generate a normally distributed random variate, truncated above.
template<matrix_order O, matrix_style S>
Matrix< double, O, S > rtanorm_combo (unsigned int rows, unsigned int cols, double mean, double variance, double above, unsigned int iter=10)
Matrix< double, Col, Concrete > rtanorm_combo (unsigned int rows, unsigned int cols, double mean, double variance, double above, unsigned int iter=10)
template<matrix_order O, matrix_style S>
Matrix< double, O, Concrete > rwish (unsigned int v, const Matrix< double, O, S > &Sigma)
 Generate a Wishart distributed random variate Matrix.
template<matrix_order O, matrix_style S>
Matrix< double, O, Concrete > rdirich (const Matrix< double, O, S > &alpha)
 Generate a Dirichlet distributed random variate Matrix.
template<matrix_order PO1, matrix_style PS1, matrix_order PO2, matrix_style PS2>
Matrix< double, PO1, Concrete > rmvnorm (const Matrix< double, PO1, PS1 > &mu, const Matrix< double, PO2, PS2 > &sigma)
 Generate a multivariate normal distributed random variate Matrix.
template<matrix_order O, matrix_style S>
Matrix< double, O, Concrete > rmvt (const Matrix< double, O, S > &sigma, double nu)
 Generate a multivariate Student t distributed random variate Matrix.

Protected Member Functions

 rng ()
 Default constructor.
RNGTYPE & as_derived ()
double rnorm1 ()
double rgamma1 (double alpha)

Protected Attributes

int rnorm_count_
double x2_
double accept_

Detailed Description

template<class RNGTYPE>
class scythe::rng< RNGTYPE >

Random number generator.

This class provides objects capable of generating random numbers from a variety of probability distributions. This abstract class forms the foundation of random number generation in Scythe. Specific random number generators should extend this class and implement the virtual void function runif(); this function should take no arguments and return uniformly distributed random numbers on the interval (0, 1). The rng class provides no interface for seed-setting or initialization, allowing for maximal flexibility in underlying implementation. This class does provide implementations of functions that return random numbers from a wide variety of commonly (and not-so-commonly) used distributions, by manipulating the uniform variates returned by runif(). See rng/mersenne.h and rng/lecuyer.h for the rng implementations offered by Scythe.

Each univariate distribution is represented by three overloaded versions of the same method. The first is a simple method returning a single value. The remaining method versions return Matrix values and are equivalent to calling the single-valued method multiple times to fill a Matrix object. They each take two arguments describing the number of rows and columns in the returned Matrix object and as many subsequent arguments as is necessary to describe the distribution. As is the case throughout the library, the Matrix-returning versions of the method include both a general and default template. We explicitly document only the single-valued versions of the univariate methods. For matrix-valued distributions we provide only a single method per distribution.

Note:
Doxygen incorrectly parses the macros we use to automatically generate the Matrix returning versions of the various univariate methods in this class. Whenever you see the macro variable __VA_ARGS__ in the public member function list below, simply substitute in the arguments in the explicitly documented single-valued version of the method.

The documentation for this class was generated from the following file: