25 #include <queso/BetaJointPdf.h> 
   26 #include <queso/GslVector.h> 
   27 #include <queso/GslMatrix.h> 
   32 template<
class V,
class M>
 
   39   BaseJointPdf<V,M>(((std::string)(prefix)+
"uni").c_str(),domainSet),
 
   56 template<
class V,
class M>
 
   61 template<
class V, 
class M>
 
   64   const V& domainVector,
 
   65   const V* domainDirection,
 
   68         V* hessianEffect)
 const 
   71   queso_require_msg(!(domainDirection || hessianMatrix || hessianEffect), 
"incomplete code for hessianMatrix and hessianEffect calculations");
 
   74   double value = std::exp(this->lnValue(domainVector,domainDirection,gradVector,hessianMatrix,hessianEffect));
 
   82     (*gradVector) *= value;
 
   88 template<
class V, 
class M>
 
   91   const V& domainVector,
 
   92   const V* domainDirection,
 
   95         V* hessianEffect)
 const 
   97   queso_require_msg(!(domainDirection || hessianMatrix || hessianEffect), 
"incomplete code for gradVector, hessianMatrix and hessianEffect calculations");
 
  101   for (
unsigned int i = 0; i < domainVector.sizeLocal(); ++i) {
 
  102     if (m_normalizationStyle == 0) {
 
  103       aux = log(m_env.basicPdfs()->betaPdfActualValue(domainVector[i],m_alpha[i],m_beta[i]));
 
  106       aux = (m_alpha[i]-1.)*log(domainVector[i]) + (m_beta[i]-1.)*log(1.-domainVector[i]);
 
  115       (*gradVector)[i] = (m_alpha[i] - 1.0) / domainVector[i] +
 
  116         (1.0 - m_beta[i]) / (1.0 - domainVector[i]);
 
  119     if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
 
  120       *m_env.subDisplayFile() << 
"In BetaJointPdf<V,M>::lnValue()" 
  121                               << 
", m_normalizationStyle = "      << m_normalizationStyle
 
  122                               << 
": domainVector[" << i << 
"] = " << domainVector[i]
 
  123                               << 
", m_alpha[" << i << 
"] = "      << m_alpha[i]
 
  124                               << 
", m_beta[" << i << 
"] = "       << m_beta[i]
 
  125                               << 
", log(pdf)= "                   << aux
 
  130   result += m_logOfNormalizationFactor;
 
  135 template<
class V, 
class M>
 
  139   unsigned int n_params = meanVector.sizeLocal();
 
  142   for (
unsigned int i = 0; i < n_params; ++i) {
 
  143     meanVector[i] = m_alpha[i] / (m_alpha[i] + m_beta[i]);
 
  147 template<
class V, 
class M>
 
  151   unsigned int n_params = m_alpha.sizeLocal();
 
  156   covMatrix.zeroLower();
 
  157   covMatrix.zeroUpper();
 
  159   for (
unsigned int i = 0; i < n_params; ++i) {
 
  160     covMatrix(i,i) = (m_alpha[i] * m_beta[i]) /
 
  161       ((m_alpha[i] + m_beta[i]) *
 
  162        (m_alpha[i] + m_beta[i]) *
 
  163        (m_alpha[i] + m_beta[i] + 1));
 
  167 template<
class V, 
class M>
 
  173   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
 
  174     *m_env.subDisplayFile() << 
"Entering BetaJointPdf<V,M>::computeLogOfNormalizationFactor()" 
  178   if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
 
  179     *m_env.subDisplayFile() << 
"Leaving BetaJointPdf<V,M>::computeLogOfNormalizationFactor()" 
  180                             << 
", m_logOfNormalizationFactor = " << m_logOfNormalizationFactor
 
std::ofstream * subDisplayFile() const 
Access function for m_subDisplayFile (displays file on stream). 
 
double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const 
Actual value of the Beta PDF. 
 
#define queso_require_equal_to_msg(expr1, expr2, msg)
 
virtual void distributionMean(V &meanVector) const 
Mean value of the underlying random variable. 
 
BetaJointPdf(const char *prefix, const VectorSet< V, M > &domainSet, const V &alpha, const V &beta)
Constructor. 
 
A templated (base) class for handling joint PDFs. 
 
double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const 
Logarithm of the value of the Beta PDF. 
 
double computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const 
Computes the logarithm of the normalization factor. 
 
#define queso_assert_equal_to(expr1, expr2)
 
A templated class for handling sets. 
 
double commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const 
Common method (to the derived classes) to compute the logarithm of the normalization factor...
 
unsigned int displayVerbosity() const 
 
~BetaJointPdf()
Destructor. 
 
A class for handling Beta joint PDFs. 
 
#define queso_require_msg(asserted, msg)
 
const BaseEnvironment & m_env
 
virtual void distributionVariance(M &covMatrix) const 
Covariance matrix of the underlying random variable.