jeudi 28 décembre 2017

How to set a vector of "discrete_distribution" c++

I'm trying to make a simulation of something like a Markov chain and using discrete_distribution to simulate the change of state s_i to s_j. But of course, this is a Matrix, not a vector. So I try.

By the way, there is a better way to initialize a vector of vectors?

std::vector <uint16_t> v1 {..., ..., ...}; // the dots are  numbers
std::vector <uint16_t> v2 {..., ..., ...};
...
std::vector <uint16_t> vn {..., ..., ...};

std::vector <std::vector <uint16_t> v {v1, v2, ..., vn};
std::vector <std::discrete_distribution <uint16_t> > distr(n, std::distribution <uint16_t> (v.begin(), v.end()) );

but this doesn't work.

note: if I try just 1 vector, this is a vector of uint16_t works

// CHANGE v by v1    
std::vector <std::discrete_distribution <uint16_t> > distr(n, std::distribution <uint16_t> (v1.begin(), v1.end()) );

I now that

std::vector <std::discrete_distribution <uint16_t> > distr(n, std::distribution <uint16_t> (v.begin(), v.end()) );

is not correct, but I say about the change v1 to v. to demonstrate that is possible use a vector of discrete distributions




Aucun commentaire:

Enregistrer un commentaire