Skip to content

Commit

Permalink
Improved NormalCopula
Browse files Browse the repository at this point in the history
Now the entropy is computed more efficiently
  • Loading branch information
regislebrun committed Jan 10, 2025
1 parent 78e9afa commit 1e88125
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/src/Uncertainty/Distribution/Normal.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ Scalar Normal::computeComplementaryCDF(const Point & point) const
/* Compute the entropy of the distribution */
Scalar Normal::computeEntropy() const
{
// The entropy is equal to (see https://statproofbook.github.io/P/mvn-dent):
// (dim/2)*(log(2pi))+(1/2)*log(det(Sigma))+(1/2)*dim
// We reuse the normalization factors to avoid the recomputation of
// the most costly parts:
// EllipticalDistribution::normalizationFactor_ == 1/sqrt(det(Sigma))
// logNormalizationFactor_ == log(1/sqrt(2*Pi)^dim)
return 0.5 * getDimension() - std::log(EllipticalDistribution::normalizationFactor_) - logNormalizationFactor_;
Expand Down
7 changes: 6 additions & 1 deletion lib/src/Uncertainty/Distribution/NormalCopula.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ CorrelationMatrix NormalCopula::getKendallTau() const
/* Compute the entropy of the distribution */
Scalar NormalCopula::computeEntropy() const
{
return normal_.computeEntropy() - getDimension() * (SpecFunc::LOGSQRT2PI + 0.5);
// The entroy of the normal copula is the entropy of
// the associated standard normal distribution minus
// dim times the entropy of a standard univariate normal
// distribution, thus it is equal to (1/2)*log(|
//return normal_.computeEntropy() - getDimension() * (SpecFunc::LOGSQRT2PI + 0.5);
return -std::log(normal_.EllipticalDistribution::normalizationFactor_);
}

/* Get the Shape matrix of the copula */
Expand Down
4 changes: 4 additions & 0 deletions lib/src/Uncertainty/Distribution/openturns/Normal.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class OT_API Normal
{

CLASSNAME

/** The NormalCopula class is closely related with the Normal class */
friend class NormalCopula;

public:

/** Default constructor */
Expand Down

0 comments on commit 1e88125

Please sign in to comment.