itpp::Normal_RNG Class Reference
Base Module » Random Number Generation

Normal distribution. More...

`#include <itpp/base/random.h>`

## Public Member Functions

| Normal_RNG (double meanval, double variance)
| Constructor. Set mean and variance.
| Normal_RNG ()
| Constructor. Set mean and variance.
void | setup (double meanval, double variance)
| Set mean, and variance.
void | get_setup (double &meanval, double &variance) const
| Get mean and variance.
double | operator() ()
| Get one sample.
vec | operator() (int n)
| Get a sample vector.
mat | operator() (int h, int w)
| Get a sample matrix.
double | sample ()
| Get a Normal distributed (0,1) sample.
void | sample_vector (int size, vec &out)
| Get a Normal distributed (0,1) vector.
void | sample_matrix (int rows, int cols, mat &out)
| Get a Normal distributed (0,1) matrix.

## Detailed Description

Normal distribution.

Normal (Gaussian) random variables, using a simplified Ziggurat method.

For details see the following arcticle: George Marsaglia, Wai Wan Tsang, "The Ziggurat Method for Generating Random Variables", Journal of Statistical Software, vol. 5 (2000), no. 8

This implementation is based on the generator written by Jochen Voss found at http://seehuhn.de/comp/ziggurat/, which is also included in the GSL library (randlist/gauss.c).

Definition at line 440 of file random.h.

## Constructor & Destructor Documentation

## Normal_RNG() [1/2]

itpp::Normal_RNG::Normal_RNG | ( | double | meanval,
|  | double | variance )

inline

Constructor. Set mean and variance.

Definition at line 444 of file random.h.

References itpp::sqrt(), and itpp::variance().

## Normal_RNG() [2/2]

itpp::Normal_RNG::Normal_RNG | ( |  | ) |

inline

Constructor. Set mean and variance.

Definition at line 447 of file random.h.

## Member Function Documentation

## setup()

void itpp::Normal_RNG::setup | ( | double | meanval,
|  | double | variance )

inline

Set mean, and variance.

Definition at line 449 of file random.h.

References itpp::variance().

## get_setup()

void itpp::Normal_RNG::get_setup | ( | double & | meanval,
|  | double & | variance ) const

Get mean and variance.

Definition at line 569 of file random.cpp.

References itpp::variance().

## operator()() [1/3]

double itpp::Normal_RNG::operator() | ( |  | ) |

inline

Get one sample.

Definition at line 454 of file random.h.

References sample().

## operator()() [2/3]

vec itpp::Normal_RNG::operator() | ( | int | n | ) |

inline

Get a sample vector.

Definition at line 456 of file random.h.

References sample_vector().

## operator()() [3/3]

mat itpp::Normal_RNG::operator() | ( | int | h,
|  | int | w )

inline

Get a sample matrix.

Definition at line 464 of file random.h.

References sample_matrix().

## sample()

double itpp::Normal_RNG::sample | ( |  | ) |

Get a Normal distributed (0,1) sample.

Definition at line 690 of file random.cpp.

References itpp::sign().

Referenced by operator()(), itpp::randn(), sample_matrix(), and sample_vector().

## sample_vector()

void itpp::Normal_RNG::sample_vector | ( | int | size,
|  | vec & | out )

inline

Get a Normal distributed (0,1) vector.

Definition at line 475 of file random.h.

References sample(), and itpp::size().

Referenced by operator()(), and itpp::randn().

## sample_matrix()

void itpp::Normal_RNG::sample_matrix | ( | int | rows,
|  | int | cols,
|  | mat & | out )

inline

Get a Normal distributed (0,1) matrix.

Definition at line 481 of file random.h.

References sample().

Referenced by operator()(), and itpp::randn().

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

- itpp/base/random.h
- itpp/base/random.cpp

Generated on for IT++ by Doxygen 1.15.0