1 #ifndef GEESE_MEAT_SIMULATE_HPP
2 #define GEESE_MEAT_SIMULATE_HPP 1
9 const std::vector< double > & par
15 std::vector< double > par0(par.begin(), par.end() -
nfunctions);
16 std::vector< double > par_root(par.end() -
nfunctions, par.end());
19 for (
auto& p : par_root) {
20 p = std::exp(p)/(std::exp(p) + 1);
24 std::vector< std::vector< size_t > >
res(
nodes.size());
27 std::vector< size_t > preorder(this->
sequence);
28 std::reverse(preorder.begin(), preorder.end());
31 std::vector< double > rootp(states.size(), 1.0);
32 for (
size_t i = 0u;
i < rootp.size(); ++
i)
35 for (
size_t j = 0u;
j <
nfuns(); ++
j)
36 rootp[
i] *= states[
i][
j] ? par_root[
j] : (1.0 - par_root[
j]);
41 std::uniform_real_distribution<> urand(0, 1);
42 double r = urand(*rengine);
44 double cumprob = rootp[idx];
45 while ((idx < rootp.size()) && (cumprob < r))
47 cumprob += rootp[++idx];
61 vector_caster< size_t, bool>(states[idx]);
64 for (
auto&
i : preorder)
78 auto tmp = model->sample(n.
narray[lth_state], par0);
std::vector< size_t > sequence
std::vector< std::vector< size_t > > simulate(const std::vector< double > &par)
std::map< size_t, Node > nodes
barry::MapVec_type< size_t > map_to_state_id
size_t nfuns() const noexcept
Number of functions analyzed.
void set_seed(const size_t &s)
A single node for the model.
std::vector< Node * > offspring
Offspring nodes.
std::vector< size_t > narray
ID of the array in the model.
size_t ord
Order in which the node was created.