double UniformJointPdf<V,M>::lnValue( const V& domainVector, const V* domainDirection, V* gradVector, M* hessianMatrix, V* hessianEffect) const { if (gradVector ) *gradVector = m_domainSet.vectorSpace().zeroVector(); if (hessianMatrix) *hessianMatrix *= 0.; if (hessianEffect) *hessianEffect = m_domainSet.vectorSpace().zeroVector(); if (domainVector[0]) {}; // just to remove compiler warning if (domainDirection) {}; // just to remove compiler warning double volume = m_domainSet.volume(); if ((queso_isnan(volume)) || (volume == -INFINITY ) || (volume == INFINITY ) || (volume <= 0. ) || (m_normalizationStyle != 0 )) { volume = 1.; } return -log(volume); }
double BaseJointPdf<V,M>::commonComputeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const { double value = 0.; double volume = m_domainSet.volume(); if ((queso_isnan(volume)) || (volume == -INFINITY ) || (volume == INFINITY ) || (volume <= 0. )) { // Do nothing } else { const BoxSubset<V,M>* boxSubset = dynamic_cast<const BoxSubset<V,M>* >(&m_domainSet); if (boxSubset == NULL) { // Do nothing } else { V tmpVec(m_domainSet.vectorSpace().zeroVector()); double sum = 0.; for (unsigned int i = 0; i < numSamples; ++i) { tmpVec.cwSetUniform(boxSubset->minValues(),boxSubset->maxValues()); sum += this->actualValue(tmpVec,NULL,NULL,NULL,NULL); } double avgValue = sum/((double) numSamples); value = -( log(avgValue) + log(volume) ); if (updateFactorInternally) { m_logOfNormalizationFactor = value; } } } return value; }
double UniformJointPdf<V,M>::actualValue( const V& domainVector, const V* domainDirection, V* gradVector, M* hessianMatrix, V* hessianEffect) const { queso_require_equal_to_msg(domainVector.sizeLocal(), this->m_domainSet.vectorSpace().dimLocal(), "invalid input"); if (gradVector ) *gradVector = m_domainSet.vectorSpace().zeroVector(); if (hessianMatrix) *hessianMatrix *= 0.; if (hessianEffect) *hessianEffect = m_domainSet.vectorSpace().zeroVector(); if (domainDirection) {}; // just to remove compiler warning double volume = m_domainSet.volume(); if ((queso_isnan(volume)) || (volume == -INFINITY ) || (volume == INFINITY ) || (volume <= 0. ) || (m_normalizationStyle != 0 )) { volume = 1.; } return 1./volume; // No need to multiply by exp(m_logOfNormalizationFactor) [PDF-04] }
double BayesianJointPdf<V,M>::computeLogOfNormalizationFactor(unsigned int numSamples, bool updateFactorInternally) const { double value = 0.; double volume = m_domainSet.volume(); if ((queso_isnan(volume)) || (volume == -INFINITY ) || (volume == INFINITY ) || (volume <= 0. )) { // Do nothing } else { queso_error_msg("incomplete code for computeLogOfNormalizationFactor()"); } return value; }