Direct Graphical Models  v.1.7.0
DirectGraphicalModels::random Namespace Reference

Random number generation. More...

Functions

template<typename T >
u (T min, T max)
 Returns an integer random number with uniform distribution. More...
 
template<typename T >
U (T min=0, T max=1)
 Returns a floating-point random number with uniform distribution. More...
 
template<typename T >
N (T mu=0, T sigma=1)
 Returns a floating-point random number with normal distribution. More...
 
Mat U (cv::Size size, int type, double min=0, double max=1)
 Returns a matrix of floating-point random numbers with uniform distribution. More...
 
Mat N (cv::Size size, int type, double mu=0, double sigma=1)
 Returns a matrix of floating-point random numbers with normal distribution. More...
 

Detailed Description

Random number generation.

This namespace collects methods for generating random numbers and vectors with uniform and normal distributions

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Function Documentation

◆ N() [1/2]

template<typename T >
T DirectGraphicalModels::random::N ( mu = 0,
sigma = 1 
)
inline

Returns a floating-point random number with normal distribution.

This function generates random numbers according to the Normal (or Gaussian) random number distribution:

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

This function is thread-safe

Template Parameters
TA floating-point type: float, double, or long double
Parameters
muThe mean \(\mu\)
sigmaThe standard deviation \(\sigma\)
Returns
A floating point number with normal distribution

Definition at line 63 of file random.h.

Here is the caller graph for this function:

◆ N() [2/2]

Mat DirectGraphicalModels::random::N ( cv::Size  size,
int  type,
double  mu = 0,
double  sigma = 1 
)
inline

Returns a matrix of floating-point random numbers with normal distribution.

Parameters
sizeSize of the resulting matrix
typeType of the resulting matrix
muThe mean \(\mu\)
sigmaThe standard deviation \(\sigma\)
Returns
A matrix of floating-point numbers with normal distribution

Definition at line 94 of file random.h.

◆ u()

template<typename T >
T DirectGraphicalModels::random::u ( min,
max 
)
inline

Returns an integer random number with uniform distribution.

This function produces random integer values i, uniformly distributed on the closed interval [min, max], that is, distributed according to the discrete probability function:

\[ P(i\,|\,min,max)=\frac{1}{max-min+1}, min \leq i \leq max \]

This function is thread-safe

Template Parameters
TAn integer type: short, int, long, long long, unsigned short, unsigned int, unsigned long, or unsigned long long
Parameters
minThe lower boudaty of the interval
maxThe upper boundary of the interval
Returns
The random number from interval [min, max]

Definition at line 29 of file random.h.

Here is the caller graph for this function:

◆ U() [1/2]

template<typename T >
T DirectGraphicalModels::random::U ( min = 0,
max = 1 
)
inline

Returns a floating-point random number with uniform distribution.

This function produces random floating-point values i, uniformly distributed on the interval [min, max), that is, distributed according to the probability function:

\[ P(i\,|\,min,max)=\frac{1}{max-min}, min \leq i < max \]

This function is thread-safe

Template Parameters
TA floating-point type: float, double, or long double
Parameters
minThe lower boudaty of the interval
maxThe upper boundary of the interval
Returns
The random number from interval [min, max)

Definition at line 46 of file random.h.

◆ U() [2/2]

Mat DirectGraphicalModels::random::U ( cv::Size  size,
int  type,
double  min = 0,
double  max = 1 
)
inline

Returns a matrix of floating-point random numbers with uniform distribution.

Parameters
sizeSize of the resulting matrix
typeType of the resulting matrix
minThe lower boundary
maxThe upper boundary
Returns
A matrix of floating-point numbers in range between [min and max)

Definition at line 79 of file random.h.