本文整理汇总了C++中SpdMatrix::logdet方法的典型用法代码示例。如果您正苦于以下问题:C++ SpdMatrix::logdet方法的具体用法?C++ SpdMatrix::logdet怎么用?C++ SpdMatrix::logdet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpdMatrix
的用法示例。
在下文中一共展示了SpdMatrix::logdet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log_model_prob
double BLSSS::log_model_prob(const Selector &g)const{
// borrowed from MLVS.cpp
double num = vpri_->logp(g);
if(num==BOOM::negative_infinity() || g.nvars() == 0) {
// If num == -infinity then it is in a zero support point in the
// prior. If g.nvars()==0 then all coefficients are zero
// because of the point mass. The only entries remaining in the
// likelihood are sums of squares of y[i] that are independent
// of g. They need to be omitted here because they are omitted
// in the non-empty case below.
return num;
}
SpdMatrix ivar = g.select(pri_->siginv());
num += .5*ivar.logdet();
if(num == BOOM::negative_infinity()) return num;
Vector mu = g.select(pri_->mu());
Vector ivar_mu = ivar * mu;
num -= .5*mu.dot(ivar_mu);
bool ok=true;
ivar += g.select(suf().xtx());
Matrix L = ivar.chol(ok);
if(!ok) return BOOM::negative_infinity();
double denom = sum(log(L.diag())); // = .5 log |ivar|
Vector S = g.select(suf().xty()) + ivar_mu;
Lsolve_inplace(L,S);
denom-= .5*S.normsq(); // S.normsq = beta_tilde ^T V_tilde beta_tilde
return num-denom;
}
示例2: log_likelihood_ivar
// The likelihood is \prod root(2pi)^-d |siginv|^{n/2} exp{-1/2 * trace(qform)}
double MvReg::log_likelihood_ivar(const Matrix &Beta,
const SpdMatrix &Siginv) const {
double qform = trace(suf()->SSE(Beta) * Siginv);
double n = suf()->n();
double normalizing_constant = -.5 * (n * ydim()) * Constants::log_2pi;
return normalizing_constant + .5 * n * Siginv.logdet() - .5 * qform;
}
示例3: dmvt
//======================================================================
double dmvt(const Vector &x, const Vector &mu,
const SpdMatrix &Siginv, double nu, bool logscale){
double ldsi = Siginv.logdet();
return dmvt(x, mu, Siginv, nu, ldsi, logscale);
}
示例4: dmvn
double dmvn(const Vector &y, const Vector &mu, const SpdMatrix &Siginv,
bool logscale) {
double ldsi = Siginv.logdet();
return dmvn(y, mu, Siginv, ldsi, logscale);
}