random.h
Go to the documentation of this file.
#ifndef RANDOM_H
#define RANDOM_H
#include <itpp/base/random_dsfmt.h>
#include <itpp/base/operators.h>
#include <itpp/itexports.h>
namespace itpp
{
ITPP_EXPORT void GlobalRNG_reset(unsigned int seed);
ITPP_EXPORT void GlobalRNG_reset();
ITPP_EXPORT unsigned int GlobalRNG_get_local_seed();
ITPP_EXPORT void GlobalRNG_randomize();
ITPP_EXPORT void GlobalRNG_get_state(ivec &state);
ITPP_EXPORT void GlobalRNG_set_state(const ivec &state);
ITPP_EXPORT void RNG_reset(unsigned int seed);
ITPP_EXPORT void RNG_reset();
ITPP_EXPORT void RNG_randomize();
ITPP_EXPORT void RNG_get_state(ivec &state);
ITPP_EXPORT void RNG_set_state(const ivec &state);
class ITPP_EXPORT Random_Generator
{
typedef random_details::ActiveDSFMT DSFMT;
public:
Random_Generator(): _dsfmt(random_details::lc_get()) {
if(!random_details::lc_is_initialized()) {
_dsfmt.init_gen_rand(GlobalRNG_get_local_seed());
random_details::lc_mark_initialized();
}
}
//Constructor using a certain seed - do not want to provide it. Use free-standing functions to change per-thread local seed
//Random_Generator(unsigned int seed) { init_gen_rand(seed); random_details::lc_mark_initialized();}
//provide wrappers for DSFMT algorithm functions
//Set the seed to a semi-random value (based on hashed time and clock) - do not want to provide it. Use free-standing functions to change per-thread local seed
//void randomize(){RNG_randomize();}
//Reset the generator with the same seed as used last time - do not want to provide it. Use free-standing functions to change per-thread local seed
//void reset() {RNG_reset();}
//Initialise the generator with a new seed (\sa init_gen_rand()) - do not want to provide it. Use free-standing functions to change per-thread local seed
//void reset(unsigned int seed) { RNG_reset(seed); }
//Resume the state of the generator from a previously saved ivec - do not want to provide it. Use free-standing functions to change per-thread local seed
//void set_state(const ivec &state) {RNG_set_state(state);}
//Return current state of generator in the form of ivec - do not want to provide it. Use free-standing functions to change per-thread local seed
//ivec get_state() const {ivec ret; RNG_get_state(ret); return ret; }
double random_01() { return genrand_open_open(); }
double random_01_lclosed() { return genrand_close_open(); }
double random_01_rclosed() { return genrand_open_close(); }
uint32_t random_int() { return genrand_uint32(); }
uint32_t genrand_uint32() { return _dsfmt.genrand_uint32(); }
double genrand_close1_open2() { return _dsfmt.genrand_close1_open2(); }
double genrand_close_open() { return genrand_close1_open2() - 1.0; }
double genrand_open_close() { return 2.0 - genrand_close1_open2(); }
double genrand_open_open() { return _dsfmt.genrand_open_open();}
private:
DSFMT _dsfmt;
};
class ITPP_EXPORT Bernoulli_RNG
{
public:
Bernoulli_RNG(double prob) { setup(prob); }
Bernoulli_RNG() { p = 0.5; }
void setup(double prob) {
it_assert(prob >= 0.0 && prob <= 1.0, "The Bernoulli source probability "
"must be between 0 and 1");
p = prob;
}
double get_setup() const { return p; }
bin operator()() { return sample(); }
bvec operator()(int n) { bvec temp(n); sample_vector(n, temp); return temp; }
bmat operator()(int h, int w) { bmat temp(h, w); sample_matrix(h, w, temp); return temp; }
bin sample() { return RNG.genrand_close_open() < p ? bin(1) : bin(0); }
void sample_vector(int size, bvec &out) {
out.set_size(size, false);
for(int i = 0; i < size; i++) out(i) = sample();
}
void sample_matrix(int rows, int cols, bmat &out) {
out.set_size(rows, cols, false);
for(int i = 0; i < rows * cols; i++) out(i) = sample();
}
protected:
private:
double p;
Random_Generator RNG;
};
class ITPP_EXPORT I_Uniform_RNG
{
public:
I_Uniform_RNG(int min = 0, int max = 1);
void setup(int min, int max);
void get_setup(int &min, int &max) const;
int operator()() { return sample(); }
ivec operator()(int n);
imat operator()(int h, int w);
int sample() {
return floor_i(RNG.genrand_close_open() * (hi - lo + 1)) + lo;
}
private:
int lo;
int hi;
Random_Generator RNG;
};
class ITPP_EXPORT Uniform_RNG
{
public:
Uniform_RNG(double min = 0, double max = 1.0);
void setup(double min, double max);
void get_setup(double &min, double &max) const;
double operator()() { return (sample() * (hi_bound - lo_bound) + lo_bound); }
vec operator()(int n) {
vec temp(n);
sample_vector(n, temp);
temp *= hi_bound - lo_bound;
temp += lo_bound;
return temp;
}
mat operator()(int h, int w) {
mat temp(h, w);
sample_matrix(h, w, temp);
temp *= hi_bound - lo_bound;
temp += lo_bound;
return temp;
}
double sample() { return RNG.genrand_close_open(); }
void sample_vector(int size, vec &out) {
out.set_size(size, false);
for(int i = 0; i < size; i++) out(i) = sample();
}
void sample_matrix(int rows, int cols, mat &out) {
out.set_size(rows, cols, false);
for(int i = 0; i < rows * cols; i++) out(i) = sample();
}
protected:
private:
double lo_bound, hi_bound;
Random_Generator RNG;
};
class ITPP_EXPORT Exponential_RNG
{
public:
Exponential_RNG(double lambda = 1.0);
void setup(double lambda) { l = lambda; }
double get_setup() const;
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int h, int w);
private:
double sample() { return (-std::log(RNG.genrand_open_close()) / l); }
double l;
Random_Generator RNG;
};
class ITPP_EXPORT Normal_RNG
{
public:
Normal_RNG(double meanval, double variance):
mean(meanval), sigma(std::sqrt(variance)) {}
Normal_RNG(): mean(0.0), sigma(1.0) {}
void setup(double meanval, double variance)
{ mean = meanval; sigma = std::sqrt(variance); }
void get_setup(double &meanval, double &variance) const;
double operator()() { return (sigma * sample() + mean); }
vec operator()(int n) {
vec temp(n);
sample_vector(n, temp);
temp *= sigma;
temp += mean;
return temp;
}
mat operator()(int h, int w) {
mat temp(h, w);
sample_matrix(h, w, temp);
temp *= sigma;
temp += mean;
return temp;
}
double sample();
void sample_vector(int size, vec &out) {
out.set_size(size, false);
for(int i = 0; i < size; i++) out(i) = sample();
}
void sample_matrix(int rows, int cols, mat &out) {
out.set_size(rows, cols, false);
for(int i = 0; i < rows * cols; i++) out(i) = sample();
}
private:
double mean, sigma;
static const double ytab[128];
static const unsigned int ktab[128];
static const double wtab[128];
static const double PARAM_R;
Random_Generator RNG;
};
class ITPP_EXPORT Gamma_RNG
{
public:
Gamma_RNG(double a = 1.0, double b = 1.0): alpha(a), beta(b) {init_state();}
void setup(double a, double b) { alpha = a; beta = b; }
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int r, int c);
double sample();
private:
void init_state();
double alpha;
double beta;
Random_Generator RNG;
Normal_RNG NRNG;
/* State variables - used in Gamma_Rng::sample()*/
double _s, _s2, _d, _scale;
double _q0, _b, _si, _c;
};
class ITPP_EXPORT Laplace_RNG
{
public:
Laplace_RNG(double meanval = 0.0, double variance = 1.0);
void setup(double meanval, double variance);
void get_setup(double &meanval, double &variance) const;
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int h, int w);
double sample() {
double u = RNG.genrand_open_open();
double l = sqrt_12var;
if(u < 0.5)
l *= std::log(2.0 * u);
else
l *= -std::log(2.0 * (1 - u));
return (l + mean);
}
private:
double mean, var, sqrt_12var;
Random_Generator RNG;
};
class ITPP_EXPORT Complex_Normal_RNG
{
public:
Complex_Normal_RNG(std::complex<double> mean, double variance):
norm_factor(1.0 / std::sqrt(2.0)) {
setup(mean, variance);
}
Complex_Normal_RNG(): m_re(0.0), m_im(0.0), sigma(1.0), norm_factor(1.0 / std::sqrt(2.0)) {}
void setup(std::complex<double> mean, double variance) {
m_re = mean.real();
m_im = mean.imag();
sigma = std::sqrt(variance);
}
void get_setup(std::complex<double> &mean, double &variance) {
mean = std::complex<double>(m_re, m_im);
variance = sigma * sigma;
}
std::complex<double> operator()() { return sigma * sample() + std::complex<double>(m_re, m_im); }
cvec operator()(int n) {
cvec temp(n);
sample_vector(n, temp);
temp *= sigma;
temp += std::complex<double>(m_re, m_im);
return temp;
}
cmat operator()(int h, int w) {
cmat temp(h, w);
sample_matrix(h, w, temp);
temp *= sigma;
temp += std::complex<double>(m_re, m_im);
return temp;
}
std::complex<double> sample() {
double a = nRNG.sample() * norm_factor;
double b = nRNG.sample() * norm_factor;
return std::complex<double>(a, b);
}
void sample_vector(int size, cvec &out) {
out.set_size(size, false);
for(int i = 0; i < size; i++) out(i) = sample();
}
void sample_matrix(int rows, int cols, cmat &out) {
out.set_size(rows, cols, false);
for(int i = 0; i < rows * cols; i++) out(i) = sample();
}
Complex_Normal_RNG & operator=(const Complex_Normal_RNG&) { return *this; }
private:
double m_re;
double m_im;
double sigma;
const double norm_factor;
Normal_RNG nRNG;
};
class ITPP_EXPORT AR1_Normal_RNG
{
public:
AR1_Normal_RNG(double meanval = 0.0, double variance = 1.0,
double rho = 0.0);
void setup(double meanval, double variance, double rho);
void get_setup(double &meanval, double &variance, double &rho) const;
void reset();
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int h, int w);
private:
double sample() {
mem *= r;
if(odd) {
r1 = m_2pi * RNG.genrand_open_close();
r2 = std::sqrt(factr * std::log(RNG.genrand_open_close()));
mem += r2 * std::cos(r1);
}
else {
mem += r2 * std::sin(r1);
}
odd = !odd;
return (mem + mean);
}
double mem, r, factr, mean, var, r1, r2;
bool odd;
Random_Generator RNG;
};
typedef Normal_RNG Gauss_RNG;
typedef AR1_Normal_RNG AR1_Gauss_RNG;
class ITPP_EXPORT Weibull_RNG
{
public:
Weibull_RNG(double lambda = 1.0, double beta = 1.0);
void setup(double lambda, double beta);
void get_setup(double &lambda, double &beta) { lambda = l; beta = b; }
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int h, int w);
private:
double sample() {
return (std::pow(-std::log(RNG.genrand_open_close()), 1.0 / b) / l);
}
double l, b;
double mean, var;
Random_Generator RNG;
};
class ITPP_EXPORT Rayleigh_RNG
{
public:
Rayleigh_RNG(double sigma = 1.0);
void setup(double sigma) { sig = sigma; }
double get_setup() { return sig; }
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int h, int w);
private:
double sample() {
double s1 = nRNG.sample();
double s2 = nRNG.sample();
// s1 and s2 are N(0,1) and independent
return (sig * std::sqrt(s1 * s1 + s2 * s2));
}
double sig;
Normal_RNG nRNG;
};
class ITPP_EXPORT Rice_RNG
{
public:
Rice_RNG(double sigma = 1.0, double v = 1.0);
void setup(double sigma, double v) { sig = sigma; s = v; }
void get_setup(double &sigma, double &v) { sigma = sig; v = s; }
double operator()() { return sample(); }
vec operator()(int n);
mat operator()(int h, int w);
private:
double sample() {
double s1 = nRNG.sample() + s;
double s2 = nRNG.sample();
// s1 and s2 are N(0,1) and independent
return (sig * std::sqrt(s1 * s1 + s2 * s2));
}
double sig, s;
Normal_RNG nRNG;
};
inline bin randb(void) { Bernoulli_RNG src; return src.sample(); }
inline void randb(int size, bvec &out) { Bernoulli_RNG src; src.sample_vector(size, out); }
inline bvec randb(int size) { bvec temp; randb(size, temp); return temp; }
inline void randb(int rows, int cols, bmat &out) { Bernoulli_RNG src; src.sample_matrix(rows, cols, out); }
inline bmat randb(int rows, int cols) { bmat temp; randb(rows, cols, temp); return temp; }
inline double randu(void) { Uniform_RNG src; return src.sample(); }
inline void randu(int size, vec &out) { Uniform_RNG src; src.sample_vector(size, out); }
inline vec randu(int size) { vec temp; randu(size, temp); return temp; }
inline void randu(int rows, int cols, mat &out) { Uniform_RNG src; src.sample_matrix(rows, cols, out); }
inline mat randu(int rows, int cols) { mat temp; randu(rows, cols, temp); return temp; }
inline int randi(int low, int high) { I_Uniform_RNG src; src.setup(low, high); return src(); }
inline ivec randi(int size, int low, int high) { I_Uniform_RNG src; src.setup(low, high); return src(size); }
inline imat randi(int rows, int cols, int low, int high) { I_Uniform_RNG src; src.setup(low, high); return src(rows, cols); }
inline vec randray(int size, double sigma = 1.0) { Rayleigh_RNG src; src.setup(sigma); return src(size); }
inline vec randrice(int size, double sigma = 1.0, double s = 1.0) { Rice_RNG src; src.setup(sigma, s); return src(size); }
inline vec randexp(int size, double lambda = 1.0) { Exponential_RNG src; src.setup(lambda); return src(size); }
inline double randn(void) { Normal_RNG src; return src.sample(); }
inline void randn(int size, vec &out) { Normal_RNG src; src.sample_vector(size, out); }
inline vec randn(int size) { vec temp; randn(size, temp); return temp; }
inline void randn(int rows, int cols, mat &out) { Normal_RNG src; src.sample_matrix(rows, cols, out); }
inline mat randn(int rows, int cols) { mat temp; randn(rows, cols, temp); return temp; }
inline std::complex<double> randn_c(void) { Complex_Normal_RNG src; return src.sample(); }
inline void randn_c(int size, cvec &out) { Complex_Normal_RNG src; src.sample_vector(size, out); }
inline cvec randn_c(int size) { cvec temp; randn_c(size, temp); return temp; }
inline void randn_c(int rows, int cols, cmat &out) { Complex_Normal_RNG src; src.sample_matrix(rows, cols, out); }
inline cmat randn_c(int rows, int cols) { cmat temp; randn_c(rows, cols, temp); return temp; }
} // namespace itpp
#endif // #ifndef RANDOM_H
itpp::Bernoulli_RNG::sample
bin sample()
Get a sample.
Definition: random.h:286
itpp::Complex_Normal_RNG
A Complex Normal Source.
Definition: random.h:579
itpp::Complex_Normal_RNG::operator()
cvec operator()(int n)
Get a sample vector.
Definition: random.h:603
itpp::Normal_RNG::sample_vector
void sample_vector(int size, vec &out)
Get a Normal distributed (0,1) vector.
Definition: random.h:475
itpp::Uniform_RNG::sample_matrix
void sample_matrix(int rows, int cols, mat &out)
Get a Uniformly distributed [0,1) matrix.
Definition: random.h:389
itpp::Bernoulli_RNG::operator()
bmat operator()(int h, int w)
Get a sample matrix.
Definition: random.h:284
itpp::GlobalRNG_get_local_seed
unsigned int GlobalRNG_get_local_seed()
Get new seed to initialize thread-local generators.
Definition: random.cpp:193
itpp::Random_Generator::random_01_lclosed
double random_01_lclosed()
Return a uniformly distributed [0,1) value.
Definition: random.h:206
itpp::m_2pi
const double m_2pi
Constant 2*Pi.
Definition: misc.h:106
itpp::Uniform_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:364
itpp::Uniform_RNG
Uniform distribution.
Definition: random.h:354
itpp::Laplace_RNG::sample
double sample()
Returns a single sample.
Definition: random.h:561
itpp::randray
vec randray(int size, double sigma=1.0)
Generates a random Rayleigh vector.
Definition: random.h:822
itpp::Complex_Normal_RNG::operator()
cmat operator()(int h, int w)
Get a sample matrix.
Definition: random.h:611
itpp::randu
double randu(void)
Generates a random uniform (0,1) number.
Definition: random.h:804
itpp::I_Uniform_RNG::setup
void setup(int min, int max)
set min and max values
Definition: random.cpp:295
itpp::randi
int randi(int low, int high)
Generates a random integer in the interval [low,high].
Definition: random.h:815
itpp::Normal_RNG
Normal distributionNormal (Gaussian) random variables, using a simplified Ziggurat method...
Definition: random.h:440
itpp::GlobalRNG_set_state
void GlobalRNG_set_state(const ivec &state)
Resume the global seed provider state saved in memory.
Definition: random.cpp:222
itpp::Complex_Normal_RNG::operator()
std::complex< double > operator()()
Get one sample.
Definition: random.h:601
itpp::Random_Generator::random_int
uint32_t random_int()
Return a uniformly distributed [0, UINT_MAX) value.
Definition: random.h:210
itpp::Gauss_RNG
Normal_RNG Gauss_RNG
Gauss_RNG is the same as Normal Source.
Definition: random.h:693
itpp::randexp
vec randexp(int size, double lambda=1.0)
Generates a random complex Gaussian vector.
Definition: random.h:828
itpp::Exponential_RNG::setup
void setup(double lambda)
Set lambda.
Definition: random.h:411
itpp::I_Uniform_RNG::sample
int sample()
Return a single value from this random generator.
Definition: random.h:338
itpp::randn
double randn(void)
Generates a random Gaussian (0,1) variable.
Definition: random.h:831
itpp::Bernoulli_RNG
Bernoulli distribution.
Definition: random.h:264
itpp::Normal_RNG::Normal_RNG
Normal_RNG(double meanval, double variance)
Constructor. Set mean and variance.
Definition: random.h:444
itpp::Normal_RNG::operator()
vec operator()(int n)
Get a sample vector.
Definition: random.h:456
itpp::Normal_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:454
itpp::Normal_RNG::Normal_RNG
Normal_RNG()
Constructor. Set mean and variance.
Definition: random.h:447
itpp::Random_Generator::genrand_open_open
double genrand_open_open()
Generate uniform (0, 1) double pseudorandom number.
Definition: random.h:254
std
STL namespace.
itpp::Gamma_RNG
Gamma distributionGenerate samples from Gamma(alpha,beta) density, according to the following equatio...
Definition: random.h:510
itpp::AR1_Normal_RNG
Filtered normal distribution.
Definition: random.h:652
itpp::Random_Generator::genrand_open_close
double genrand_open_close()
Generate uniform (0, 1] double pseudorandom number.
Definition: random.h:244
itpp::Complex_Normal_RNG::get_setup
void get_setup(std::complex< double > &mean, double &variance)
Get mean and variance.
Definition: random.h:596
itpp::Rice_RNG::get_setup
void get_setup(double &sigma, double &v)
Get parameters.
Definition: random.h:771
itpp::Rayleigh_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:743
itpp::Uniform_RNG::operator()
mat operator()(int h, int w)
Get a sample matrix.
Definition: random.h:374
itpp::Normal_RNG::sample
double sample()
Get a Normal distributed (0,1) sample.
Definition: random.cpp:690
itpp::Random_Generator::Random_Generator
Random_Generator()
Default constructor.
Definition: random.h:176
it_assert
#define it_assert(t, s)
Abort if t is not true.
Definition: itassert.h:94
itpp::Complex_Normal_RNG::sample_matrix
void sample_matrix(int rows, int cols, cmat &out)
Get a Complex Normal (0,1) distributed matrix.
Definition: random.h:632
itpp::Complex_Normal_RNG::sample
std::complex< double > sample()
Get a Complex Normal (0,1) distributed sample.
Definition: random.h:619
itpp::GlobalRNG_reset
void GlobalRNG_reset(unsigned int seed)
Set the internal seed of the Global Seed Provider.
Definition: random.cpp:176
itpp::Laplace_RNG
Laplacian distribution.
Definition: random.h:545
itpp::Complex_Normal_RNG::setup
void setup(std::complex< double > mean, double variance)
Set mean and variance.
Definition: random.h:590
itpp::I_Uniform_RNG::operator()
int operator()()
Get one sample.
Definition: random.h:332
itpp::AR1_Gauss_RNG
AR1_Normal_RNG AR1_Gauss_RNG
AR1_Gauss_RNG is the same as AR1_Normal_RNG.
Definition: random.h:699
itpp::random_details::DSFMT
C++ implementation of dSFMT random number generator.
Definition: random_dsfmt.h:98
itpp::Rice_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:773
itpp::mean
double mean(const vec &v)
The mean value.
Definition: misc_stat.cpp:36
itpp::sin
vec sin(const vec &x)
Sine function.
Definition: trig_hyp.h:54
itpp::Uniform_RNG::operator()
vec operator()(int n)
Get a sample vector.
Definition: random.h:366
itpp::log
vec log(const vec &x)
The natural logarithm of the elements.
Definition: log_exp.h:241
itpp::variance
double variance(const cvec &v)
The variance of the elements in the vector. Normalized with N-1 to be unbiased.
Definition: misc_stat.cpp:159
itpp::Complex_Normal_RNG::operator=
Complex_Normal_RNG & operator=(const Complex_Normal_RNG &)
Dummy assignment operator - MSVC++ warning C4512.
Definition: random.h:638
itpp::min
T min(const Vec< T > &in)
Minimum value of vector.
Definition: min_max.h:125
itpp::Complex_Normal_RNG::Complex_Normal_RNG
Complex_Normal_RNG(std::complex< double > mean, double variance)
Constructor. Set mean and variance.
Definition: random.h:583
itpp::Bernoulli_RNG::Bernoulli_RNG
Bernoulli_RNG(double prob)
Binary source with probability prob for a 1.
Definition: random.h:268
itpp::Laplace_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:555
itpp::Rayleigh_RNG::get_setup
double get_setup()
Get sigma.
Definition: random.h:741
itpp::Random_Generator::genrand_uint32
uint32_t genrand_uint32()
Generate uniform [0, UINT_MAX) integer pseudorandom number.
Definition: random.h:213
itpp::Rayleigh_RNG
Rayleigh distribution.
Definition: random.h:733
itpp::RNG_randomize
void RNG_randomize()
Set a random seed for all Random Number Generators in the current thread.
Definition: random.cpp:254
itpp::max
T max(const Vec< T > &v)
Maximum value of vector.
Definition: min_max.h:45
random_dsfmt.h
C++ implementation of dSFMT random number generator.
itpp::random_details::lc_mark_initialized
void lc_mark_initialized()
Function to mark thread-local context as initialized.
Definition: random.cpp:57
itpp::Weibull_RNG
Weibull distribution.
Definition: random.h:705
itpp::RNG_reset
void RNG_reset(unsigned int seed)
Set the seed for all Random Number Generators in the current thread.
Definition: random.cpp:230
itpp::Weibull_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:715
itpp::Random_Generator
Base class for random (stochastic) sources.
Definition: random.h:171
itpp::pow
vec pow(const double x, const vec &y)
Calculates x to the power of y (x^y)
Definition: log_exp.h:176
itpp::size
int size(const Vec< T > &v)
Length of vector.
Definition: matfunc.h:55
itpp::Gamma_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:518
itpp::Complex_Normal_RNG::Complex_Normal_RNG
Complex_Normal_RNG()
Default constructor.
Definition: random.h:588
itpp::Normal_RNG::operator()
mat operator()(int h, int w)
Get a sample matrix.
Definition: random.h:464
operators.h
Definitions of operators for vectors and matricies of different types.
itpp::randb
bin randb(void)
Generates a random bit (equally likely 0s and 1s)
Definition: random.h:793
itpp::floor_i
int floor_i(double x)
The nearest smaller integer.
Definition: converters.h:350
itpp
itpp namespace
Definition: itmex.h:36
itpp::Exponential_RNG
Exponential distribution.
Definition: random.h:405
itpp::RNG_set_state
void RNG_set_state(const ivec &state)
Resume Random Number generation in the current thread with previously stored context.
Definition: random.cpp:274
itpp::Gamma_RNG::setup
void setup(double a, double b)
Set alpha and beta.
Definition: random.h:516
itpp::random_details::lc_is_initialized
bool lc_is_initialized()
Function to check if thread-local context is initialized.
Definition: random.cpp:52
itpp::Bernoulli_RNG::get_setup
double get_setup() const
return the probability
Definition: random.h:278
itpp::Bernoulli_RNG::operator()
bin operator()()
Get one sample.
Definition: random.h:280
itpp::GlobalRNG_get_state
void GlobalRNG_get_state(ivec &state)
Save current full state of global seed provider in memory.
Definition: random.cpp:213
itpp::random_details::lc_get
ActiveDSFMT::Context & lc_get()
Function to access thread-local context for random numbers generation.
Definition: random.cpp:47
itpp::Exponential_RNG::operator()
double operator()()
Get one sample.
Definition: random.h:415
itpp::Complex_Normal_RNG::sample_vector
void sample_vector(int size, cvec &out)
Get a Complex Normal (0,1) distributed vector.
Definition: random.h:626
itpp::Bernoulli_RNG::sample_vector
void sample_vector(int size, bvec &out)
Get a sample vector.
Definition: random.h:288
itpp::GlobalRNG_randomize
void GlobalRNG_randomize()
Set a random seed for the Global Seed Provider seed.
Definition: random.cpp:204
itpp::bin
Binary arithmetic (boolean) class.
Definition: binary.h:56
itpp::RNG_get_state
void RNG_get_state(ivec &state)
Save Random Number generation context used in the current thread.
Definition: random.cpp:262
itpp::Uniform_RNG::sample
double sample()
Get a Uniformly distributed [0,1) sample.
Definition: random.h:382
itpp::Bernoulli_RNG::sample_matrix
void sample_matrix(int rows, int cols, bmat &out)
Get a sample matrix.
Definition: random.h:293
itpp::Rice_RNG
Rice distribution.
Definition: random.h:763
itpp::Uniform_RNG::sample_vector
void sample_vector(int size, vec &out)
Get a Uniformly distributed [0,1) vector.
Definition: random.h:384
itpp::Random_Generator::genrand_close_open
double genrand_close_open()
Generate uniform [0, 1) double pseudorandom number.
Definition: random.h:234
itpp::Gamma_RNG::Gamma_RNG
Gamma_RNG(double a=1.0, double b=1.0)
Constructor, which sets alpha (a) and beta (b)
Definition: random.h:514
itpp::sqrt
vec sqrt(const vec &x)
Square root of the elements.
Definition: elem_math.h:123
itpp::Rice_RNG::setup
void setup(double sigma, double v)
Set sigma, and v (if v = 0, Rice -> Rayleigh).
Definition: random.h:769
itpp::Normal_RNG::setup
void setup(double meanval, double variance)
Set mean, and variance.
Definition: random.h:449
itpp::Normal_RNG::sample_matrix
void sample_matrix(int rows, int cols, mat &out)
Get a Normal distributed (0,1) matrix.
Definition: random.h:481
itpp::Bernoulli_RNG::operator()
bvec operator()(int n)
Get a sample vector.
Definition: random.h:282
itpp::Weibull_RNG::get_setup
void get_setup(double &lambda, double &beta)
Get lambda and beta.
Definition: random.h:713
itpp::Random_Generator::random_01_rclosed
double random_01_rclosed()
Return a uniformly distributed (0,1] value.
Definition: random.h:208
itpp::Rayleigh_RNG::setup
void setup(double sigma)
Set sigma.
Definition: random.h:739
itpp::Random_Generator::genrand_close1_open2
double genrand_close1_open2()
Generate uniform [1, 2) double pseudorandom number.
Definition: random.h:224
itpp::cos
vec cos(const vec &x)
Cosine function.
Definition: trig_hyp.h:58
itpp::Random_Generator::random_01
double random_01()
Return a uniformly distributed (0,1) value.
Definition: random.h:204
itpp::Bernoulli_RNG::Bernoulli_RNG
Bernoulli_RNG()
Binary source with probability prob for a 1.
Definition: random.h:270
itpp::AR1_Normal_RNG::operator()
double operator()()
Get a single random sample.
Definition: random.h:665
itpp::I_Uniform_RNG
Integer uniform distributionExample: Generation of random uniformly distributed integers in the inter...
Definition: random.h:322
itpp::randrice
vec randrice(int size, double sigma=1.0, double s=1.0)
Generates a random Rice vector (See J.G. Poakis, "Digital Communications, 3rd ed." p...
Definition: random.h:825
bmat
Mat< bin > bmat
bin matrix
Definition: mat.h:508
itpp::randn_c
std::complex< double > randn_c(void)
Generates a random complex Gaussian (0,1) variable.
Definition: random.h:845
itpp::Bernoulli_RNG::setup
void setup(double prob)
set the probability
Definition: random.h:272

Generated on Thu Aug 20 2015 21:02:50 for IT++ by Doxygen 1.8.9.1