Add entropy dispatch for distributions - #8375
Draft
uditjainstjis wants to merge 2 commits into
Draft
Conversation
|
|
Implements an `entropy` dispatcher under `pymc.distributions.moments`, mirroring the existing `mean` dispatch (pymc-devs#7530). It returns the differential entropy for continuous distributions and the Shannon entropy (in nats) for discrete ones, following the `scipy.stats` convention. Closed-form entropies are registered for the univariate distributions (Normal, Uniform, Exponential, Laplace, AsymmetricLaplace, Cauchy, HalfCauchy, HalfNormal, Gamma, InverseGamma, Beta, Logistic, LogNormal, Gumbel, Pareto, Weibull, StudentT, Triangular, Moyal, VonMises, Bernoulli, Geometric, DiscreteUniform, Categorical) as well as MvNormal and Dirichlet. ChiSquared is covered automatically through its Gamma parametrization. Every value is checked against `scipy.stats`'s `entropy`, and the result is verified to be differentiable w.r.t. the distribution parameters (the regularization use case motivating the issue). Distributions without a closed-form entropy raise NotImplementedError. Closes pymc-devs#8085
uditjainstjis
force-pushed
the
entropy-dispatch
branch
from
July 23, 2026 23:32
0d3da81 to
5946ebd
Compare
Author
|
Checking in on this one — it's been parked on the design question of whether the entropy implementations belong here or in a separate distributions package. Is there a decision I should build against, or something smaller I could split out in the meantime? The 26 distributions are backed by 44 scipy-verified tests, so I'd rather land it in whatever shape you want than leave it sitting. |
Member
|
I'd suggest the pytensor-distributions, we already have the POC PR happening in #8376 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds an
entropydispatcher underpymc.distributions.moments, mirroring the existingmeandispatch (#7530).entropy(rv)returns the differential entropy for continuous distributions and the Shannon entropy (in nats) for discrete ones, following thescipy.statsconvention.Closed-form entropies are registered per RV
Opfor the univariate distributions — Normal, Uniform, Exponential, Laplace, AsymmetricLaplace, Cauchy, HalfCauchy, HalfNormal, Gamma, InverseGamma, Beta, Logistic, LogNormal, Gumbel, Pareto, Weibull, StudentT, Triangular, Moyal, VonMises, Bernoulli, Geometric, DiscreteUniform, Categorical — plus MvNormal and Dirichlet. ChiSquared is covered automatically via its Gamma parametrization. Distributions without a closed-form entropy remain unregistered and raiseNotImplementedError.This keeps the helper self-contained in PyMC with no new dependency on
pytensor-distributions, consistent with @ricardoV94's note in the issue that these derived stats "will remain PyMC specific", and with howmean(#7530) is already implemented. Happy to reroute through thedistributionspackage instead if that's preferred — see my comment on the issue. Opening as a draft since the issue was parked pending the (now-shipped) v0 release.Related Issue
entropydispatches for distributions #8085Checklist
scipy.stats'sentropy; batched/tiled cases and theNotImplementedErrorpath covered)Type of change