Sample exactly from the discrete normal distribution.
More...
#include <exrandom/discrete_normal_distribution.hpp>
Sample exactly from the discrete normal distribution.
This samples from the discrete normal distribution Pi ∝ exp[− ((i − μ)/σ)2/2], where μ and σ > 0 are specified as rational numbers (the ratio of two ints). This implements Algorithm D with improvements due to Du et al. (2020).
This is a wrapper for discrete_normal_dist to turn it into a C++11 style random distribution. The base for discrete_normal_dist is set to 216.
- Examples
- chisq_test.cpp, compare_times.cpp, exrandom_test.cpp, sample_distributions.cpp, and simple_discrete_normal.cpp.
Definition at line 33 of file discrete_normal_distribution.hpp.
◆ result_type
◆ discrete_normal_distribution() [1/5]
exrandom::discrete_normal_distribution::discrete_normal_distribution |
( |
| ) |
|
|
inlineexplicit |
◆ discrete_normal_distribution() [2/5]
exrandom::discrete_normal_distribution::discrete_normal_distribution |
( |
const param_type & |
p | ) |
|
|
inlineexplicit |
◆ discrete_normal_distribution() [3/5]
exrandom::discrete_normal_distribution::discrete_normal_distribution |
( |
int |
mu, |
|
|
int |
sigma |
|
) |
| |
|
inlineexplicit |
Construct with integer parameters.
- Parameters
-
mu | the value of μ. |
sigma | the value of σ. |
Sets μ = mu and σ = sigma.
Definition at line 120 of file discrete_normal_distribution.hpp.
◆ discrete_normal_distribution() [4/5]
exrandom::discrete_normal_distribution::discrete_normal_distribution |
( |
int |
mu_num, |
|
|
int |
sigma_num, |
|
|
int |
den |
|
) |
| |
|
inlineexplicit |
Construct with parameters with a common denominator.
- Parameters
-
mu_num | the numerator of μ. |
sigma_num | the numerator of σ. |
den | the common denominator. |
Sets μ = mu_num / den and σ = sigma_num / den.
Definition at line 134 of file discrete_normal_distribution.hpp.
◆ discrete_normal_distribution() [5/5]
exrandom::discrete_normal_distribution::discrete_normal_distribution |
( |
int |
mu_num, |
|
|
int |
mu_den, |
|
|
int |
sigma_num, |
|
|
int |
sigma_den |
|
) |
| |
|
inlineexplicit |
Construct from the individual parameters.
- Parameters
-
mu_num | the numerator of μ. |
mu_den | the denominator of μ. |
sigma_num | the numerator of σ. |
sigma_den | the denominator of σ. |
Sets μ = mu_num / mu_den and σ = sigma_num / sigma_den.
Definition at line 149 of file discrete_normal_distribution.hpp.
◆ reset()
void exrandom::discrete_normal_distribution::reset |
( |
| ) |
|
|
inline |
◆ mu_num()
result_type exrandom::discrete_normal_distribution::mu_num |
( |
| ) |
const |
|
inline |
◆ mu_den()
result_type exrandom::discrete_normal_distribution::mu_den |
( |
| ) |
const |
|
inline |
◆ sigma_num()
result_type exrandom::discrete_normal_distribution::sigma_num |
( |
| ) |
const |
|
inline |
◆ sigma_den()
result_type exrandom::discrete_normal_distribution::sigma_den |
( |
| ) |
const |
|
inline |
◆ param() [1/2]
param_type exrandom::discrete_normal_distribution::param |
( |
| ) |
const |
|
inline |
◆ param() [2/2]
void exrandom::discrete_normal_distribution::param |
( |
const param_type & |
param | ) |
|
|
inline |
◆ min()
result_type exrandom::discrete_normal_distribution::min |
( |
| ) |
const |
|
inline |
◆ max()
result_type exrandom::discrete_normal_distribution::max |
( |
| ) |
const |
|
inline |
◆ operator()() [1/2]
template<typename Generator >
result_type exrandom::discrete_normal_distribution::operator() |
( |
Generator & |
g | ) |
|
|
inline |
◆ operator()() [2/2]
template<typename Generator >
- Template Parameters
-
- Parameters
-
g | the random generator engine. |
p | a parameter set. |
- Returns
- a discrete normal deviate using the specified parameters.
Definition at line 216 of file discrete_normal_distribution.hpp.
◆ operator==
◆ operator!=
◆ operator<<
◆ operator>>
The documentation for this class was generated from the following file: