ExRandom
3.0
|
Partially sample exactly from the discrete normal distribution. More...
#include <exrandom/discrete_normal_dist.hpp>
Classes | |
struct | param_type |
Hold the parameters of discrete_normal_dist. More... | |
Public Member Functions | |
discrete_normal_dist (digit_gen &D) | |
discrete_normal_dist (digit_gen &D, const param_type &p) | |
discrete_normal_dist (digit_gen &D, int mu, int sigma) | |
discrete_normal_dist (digit_gen &D, int mu_num, int sigma_num, int den) | |
discrete_normal_dist (digit_gen &D, int mu_num, int mu_den, int sigma_num, int sigma_den) | |
int | mu_num () const |
int | mu_den () const |
int | sigma_num () const |
int | sigma_den () const |
template<typename Generator > | |
void | generate (Generator &g, i_rand< digit_gen > &j) |
template<typename Generator > | |
int | operator() (Generator &g) |
digit_gen & | digit_generator () const |
const param_type & | param () const |
void | init (const param_type ¶m) |
Partially sample exactly from the discrete normal distribution.
This samples from the discrete normal distribution Pi ∝ exp[− ((i − μ)/σ)2/2]. This implements Algorithm D with improvements due to Du et al. (2020).
digit_gen | the type of digit generator. |
This class allows a i_rand to be returned via the discrete_normal_dist::generate member function or an int result via the discrete_normal_dist::operator()() member function.
See discrete_normal_distribution for a simpler interface to sampling discrete normal deviates. (But, you can't obtain an i_rand with this class.)
Definition at line 40 of file discrete_normal_dist.hpp.
|
inline |
The default constructor.
D | a reference to the digit generator to be used. |
Sets μ = 0 and σ = 1.
Definition at line 179 of file discrete_normal_dist.hpp.
|
inline |
Construct from a param_type.
D | a reference to the digit generator to be used. |
p | the param_type. |
Definition at line 189 of file discrete_normal_dist.hpp.
|
inline |
Construct with integer parameters.
D | a reference to the digit generator to be used. |
mu | the value of μ. |
sigma | the value of σ. |
Sets μ = mu and σ = sigma.
Definition at line 202 of file discrete_normal_dist.hpp.
|
inline |
Construct with parameters with a common denominator.
D | a reference to the digit generator to be used. |
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 216 of file discrete_normal_dist.hpp.
|
inline |
Construct from the individual parameters.
D | a reference to the digit generator to be used. |
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 232 of file discrete_normal_dist.hpp.
|
inline |
Definition at line 242 of file discrete_normal_dist.hpp.
|
inline |
Definition at line 246 of file discrete_normal_dist.hpp.
|
inline |
Definition at line 250 of file discrete_normal_dist.hpp.
|
inline |
Definition at line 254 of file discrete_normal_dist.hpp.
|
inline |
Return a deviate as a i_rand.
Generator | the type of g. |
g | the random generator engine. |
j | the i_rand to set. |
Definition at line 264 of file discrete_normal_dist.hpp.
|
inline |
Return a deviate.
Generator | the type of g. |
g | the random generator engine. |
Definition at line 317 of file discrete_normal_dist.hpp.
|
inline |
Definition at line 324 of file discrete_normal_dist.hpp.
|
inline |
Definition at line 328 of file discrete_normal_dist.hpp.
|
inline |
Set new parameters.
param | the new parameters. |
Definition at line 334 of file discrete_normal_dist.hpp.