Esempio n. 1
0
Scene::Scene(GuiWidgets* _gw) :
gw(*_gw), 
is_visible(true),    // should be set to false when the window is iconified !!!!
is_initialized(false),
is_startCB_launched(false),
net_delay(500),
cycles(0),
hud(NULL)
{
  background = UBackground::black;
  addAttr(background);
  addAttr(usize(g.pref.width3D, g.pref.height3D));

  hudbox.addAttr(upos(1, 1)  // position relatively to the canvas : up left corner
                 + UOrient::vertical + UHalign::left
                 + UFont::small + UColor::yellow   // size & color of the text
                 );
  hudbox.add(hud_line1 + hud_line2 + hud_line3 + hud_line4 + hud_line5);
  add(hudbox);	// add the hudbox to the scene

  message.addAttr(UFont::bold + UFont::xx_large + UColor::orange + uhcenter() + uvcenter());
  message.add("Please wait, VReng is coming up...");
  add(uhflex() + uvflex() + message);
  
  // Paint and Resize functions:
  // - are callback functions (paintCB and resizeCB) if the Scene is a UBox 
  // - are redefinitions of paintGL and resizeGL if the Scene is a UGlcanvas
  addAttr(UOn::paint / ucall(this, &Scene::paintCB)
          + UOn::resize / ucall(this, &Scene::resizeCB));
}
Esempio n. 2
0
rowvec dF1du(unsigned row, unsigned cause, unsigned indiv, unsigned cond_cause, const DataPairs &data, const gmat &sigma, vec u){

  // Other individual
  unsigned cond_indiv;
  if (indiv==0){
    cond_indiv=1;
  }
  else {
    cond_indiv=0;
  }

  // Alpgam of other individual
  double cond_alp = data.alphaMarg_get(row, cond_cause, cond_indiv);
  double cond_gam = data.gammaMarg_get(row, cond_cause, cond_indiv);
  double cond_alpgam = cond_alp - cond_gam;

  vec vcond_alpgam(1); vcond_alpgam(0) = cond_alpgam;

  // Joining u vector and alpgam from other individual
  vec alpgamu = join_cols(vcond_alpgam, u);

  // Attaining variance covariance matrix etc. (conditional on u and other individual)
  vmat cond_sig = sigma(cause,cond_cause);
  double cond_mean = as_scalar(cond_sig.proj*alpgamu);

  double alp = data.alphaMarg_get(row, cause, indiv);
  double gam = data.gammaMarg_get(row, cause, indiv);
  double alpgam = alp - gam;
  double c_alpgam = alpgam - cond_mean;

  double inner = pow((c_alpgam),2)*as_scalar(cond_sig.inv);

  double cdf = pn(alpgam, cond_mean, as_scalar(cond_sig.vcov));
  double pdf = invsqtwopi*1/sqrt(as_scalar(cond_sig.vcov))*exp(-0.5*inner);

  uvec upos = zeros<uvec>(u.n_rows);
  for (unsigned h=0; h<u.n_rows; h++){
    upos(h) = h + 1;
  };

  mat proj = cond_sig.proj;
  rowvec dcdfdu = pdf*(-proj.cols(upos));
  rowvec dF1du = data.dpiduMarg_get(row, cause, indiv)*cdf + data.piMarg_get(row, cause, indiv)*dcdfdu;

  return(dF1du);
};