dimanche 31 juillet 2016

Are C++ distributions keep or update parameters on op(URNG, params)?

Question to C++ language lawyers, applicable to pretty much any distribution (normal, uniform, poisson, ...), but I'll use Poisson as an example.

Simple code

#include <random>

std::default_random_engine rng;

double lambda = 5.0;
std::poisson_distribution<int> Poisson(lambda);

auto A = Poisson(rng);      // call with lambda equal to 5
auto B = Poisson(rng, 3.0); // call with lambda equal to 3
auto C = Poisson(rng);      // call with lambda equal to what?

What lambda would be used in case of C?

All distribution have the same overloaded operators:

template<class URNG> result_type operator()(URNG& g);
template<class URNG> result_type operator()(URNG& g, const param_type& parm);

If we construct distribution with one set of parameteres, then call second op(), will distribution state altered? Or it will use parameters from the constructor?




Aucun commentaire:

Enregistrer un commentaire