Example #1
0
 double PDM::pdf(const Matrix &Pi, bool logscale) const {
   double ans(0);
   for (uint i = 0; i < Pi.nrow(); ++i) {
     ans += ddirichlet(Pi.row(i), Nu().row(1), true);
   }
   return logscale ? ans : exp(ans);
 }
Example #2
0
Foam::tmp<Foam::volScalarField>
Foam::heatTransferModels::RanzMarshall::K() const
{
    volScalarField Nu(scalar(2) + 0.6*pair_.Re()*cbrt(pair_.Pr()));

    return 6.0*pair_.continuous().kappa()*Nu/sqr(pair_.dispersed().d());
}
Example #3
0
 PDM::ProductDirichletModel(const Vector &wgt, const Matrix &Pi)
     : ParamPolicy(new MatrixParams(Pi)),
       DataPolicy(new PDS(wgt.size())),
       PriorPolicy() {
   SpdMatrix W(wgt.size());
   W.set_diag(wgt);
   set_Nu(W * Nu());
 }
Example #4
0
  void MCS::check_pi0()const{
    if(!!pi0_) return;
    ostringstream err;
    err << "A Markov chain model has a free initial distribution "
	<< "parameter (pi0) that was not assigned a prior."
	<< endl
	<< "Prior for transition counts was:" <<endl
	<< Nu() << endl;
    throw_exception<std::runtime_error>(err.str());
  }
Example #5
0
  double PDM::loglike(const Vector &Nu_columns) const {
    Matrix Nu(dim(), dim(), Nu_columns.data());
    const Matrix &sumlog(suf()->sumlog());
    double n = suf()->n();

    double ans = 0;
    for (uint i = 0; i < nrow(Nu); ++i)
      ans += dirichlet_loglike(Nu.row(i), 0, 0, sumlog.row(i), n);
    return ans;
  }
Example #6
0
 void MVT::mle() {
   const double eps = 1e-5;
   double dloglike = eps + 1;
   double loglike = this->loglike(vectorize_params());
   double old = loglike;
   Vector Nu(1, nu());
   while (dloglike > eps) {
     Estep();
     mvn->mle();
     MvtNuTF f(this);
     loglike = max_nd1(Nu, Target(f), dTarget(f));
     set_nu(Nu[0]);
     dloglike = loglike - old;
     old = loglike;
   }
 }
Example #7
0
scalar RanzMarshall::relaxationTime
(
    const scalar liquidDensity,
    const scalar diameter,
    const scalar liquidcL,
    const scalar kappa,
    const scalar ReynoldsNumber,
    const scalar PrandtlNumber
) const
{
    scalar time = liquidDensity*pow(diameter, 2.0)*liquidcL/(6.0*kappa*Nu(ReynoldsNumber, PrandtlNumber));

    time = max(SMALL, time);

    return time;
}
Example #8
0
  double PDM::dloglike(const Vector &Nu_columns, Vector &g) const {
    Matrix Nu(dim(), dim(), Nu_columns.data());
    const Matrix &sumlog(suf()->sumlog());
    double n = suf()->n();

    uint nr = nrow(Nu);
    Matrix G(nr, nr);
    Vector g_row(nr);

    double ans = 0;
    for (uint i = 0; i < nrow(Nu); ++i) {
      ans += dirichlet_loglike(Nu.row(i), &g_row, 0, sumlog.row(i), n);
      G.row(i) = g_row;
    }
    G = G.transpose();
    g.assign(G.begin(), G.end());

    // need to check that g is vectorized in the right way..  virtual
    // functions might expect columns instead of rows.
    return ans;
  }
void PDPS::draw(){

  const Mat & sumlog(m_->suf()->sumlog());
  double nobs(m_->suf()->n());
  Mat Nu(m_->Nu());
  uint d= nrow(Nu);
  for(uint i=0; i<d; ++i){
    Vec sumlog_i(sumlog.row(i));
    Vec nu(Nu.row(i));
    for(uint j=0; j<d; ++j){
      DirichletLogp logp(j, nu, sumlog_i, nobs,
                         phi_row_prior_[i], alpha_row_prior_[i],
                         min_nu_);
      ScalarSliceSampler sam(logp, true);
      sam.set_lower_limit(min_nu_);
      nu[j]= sam.draw(nu[j]);
    }
    Nu.row(i) = nu;
  }

  m_->set_Nu(Nu);
}
void CEmpEdit::OnBnClickedButton5()
{
	// TODO: Add
	CString SqlString,s1;
	CString var_name,var_id,var_sh,var_sa,var_dep;
	// ( [Employee ID], [Employee Name], [Deprtment], [Shift], [Salary]) 
//	int s;
	s1.Format("INSERT INTO EmpTable ( [Employee ID], [Employee Name], [Deprtment], [Shift], [Salary] )  VALUES ( ");
	int flg=0;
	EID->GetWindowText(var_id);
	ENA->GetWindowText(var_name);
	EWO->GetWindowText(var_sh);
	ESA->GetWindowText(var_sa);
	EDE->GetWindowText(var_dep);
	
	//int p=_ttoi(var_price);
	CString coma(", ");
	CString CB(" );");
	CString Quo("'");
	CString Nu(" NULL ,");
	SqlString=s1+Quo+var_id+Quo+coma+Quo+var_name+Quo+coma+Quo+var_dep+Quo+coma+Quo+var_sh+Quo+coma+var_sa+CB;
	
	try
{
   database.ExecuteSQL(SqlString);
}
catch(CDBException* pe)
{
	flg=1;
   // The error code is in pe->m_nRetCode
   pe->ReportError();
   pe->Delete();
}
if (flg == 0)
{
MessageBox(_T("Record Successfully Added To The Database"),_T("Successfull")); 
}
	}
 void DM::set_nu(const Vector &newnu) { Nu()->set(newnu); }
 const Vector &DM::nu() const { return Nu()->value(); }
Example #13
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;
 }
Example #14
0
 uint PDM::dim() const { return Nu().nrow(); }