Beispiel #1
0
  void MCS::draw(){
    const Mat & Nu(this->Nu());
    Mat Q(mod_->Q());
    const Mat & N(mod_->suf()->trans());
    assert(Nu.same_dim(Q));
    uint S = Nu.nrow();
    for(uint s=0; s<S; ++s){
      wsp = Nu.row(s) + N.row(s);
      Q.row(s) = rdirichlet_mt(rng(), wsp);
    }
    mod_->set_Q(Q);

//     cout << "drawing Q:  trans = " << endl
//          << N <<endl;

    if(mod_->pi0_fixed()) return;
    check_pi0();
    wsp = this->nu() + mod_->suf()->init();
    //    cout << "drawing pi0:  nu = " << wsp << endl;
    mod_->set_pi0( rdirichlet_mt(rng(), wsp));
  }
 Vector DirichletModel::sim(RNG &rng) const {
   return rdirichlet_mt(rng, nu());
 }
 void MDS::draw(){
   Vec counts = pri_->nu() +  mod_->suf()->n();
   Vec pi = rdirichlet_mt(rng(), counts);
   mod_->set_pi(pi);
 }
Beispiel #4
0
 Matrix PDM::sim(RNG &rng) const {
   uint d = dim();
   Matrix ans(d, d);
   for (uint i = 0; i < d; ++i) ans.row(i) = rdirichlet_mt(rng, Nu().row(i));
   return ans;
 }