Use pytensor-distributions for Normal logp, logcdf, logccdf and icdf - #8376
Use pytensor-distributions for Normal logp, logcdf, logccdf and icdf#8376juanitorduz wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I need one analysis of the logp_dlogp that |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8376 +/- ##
==========================================
+ Coverage 91.82% 91.85% +0.02%
==========================================
Files 128 128
Lines 21110 21257 +147
==========================================
+ Hits 19384 19525 +141
- Misses 1726 1732 +6
🚀 New features to boost your workflow:
|
Makes sense @ricardoV94 , will you do it or do you want me to put together a little script? |
if you have capacity now go ahead, I'm swamped until next week |
Per review, cap the new dependency so a future breaking release does not force a rushed fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Before/after analysis of model.logp_dlogp_function(ravel_inputs=True) requested in review: dprint with print_memory_map=True, timings, op counts, and value checks. See PTD_NORMAL_BENCHMARK.md for results. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ricardoV94 in 6ca7f7c I asked Claude tu run this one-off analysis. Is this helpful? You can iterate over it. I will remove it if we decide to merge |
|
@ricardoV94 here is the
Also applied the 🤖 Generated with Claude Code |
|
Yeha that's the sort of stuff. It should check symbolic mu/log(sigma) and variants with constant and symbolic data. data is not "always" constant. The logsf should be patched upstream yes |
Description
Proof of concept for delegating distribution math to the new pytensor-distributions package, starting with
Normal.Normal.logp,logcdf,logccdfandicdfnow callpytensor_distributions.normal.logpdf/logcdf/logsf/ppfinstead of the inline formulas. The expressions are mathematically identical to the previous ones (logsfuses the same erfcx-based asymptotic switch asnormal_lccdf, anderfinv(2q-1) ≡ -erfcinv(2q)for the icdf), so numerical behavior is unchanged.check_parameters/check_icdf_parameters(sigma > 0) wrappers are kept. Thecheck_icdf_valuewrapper was dropped becauseppfalready boundsq(NaN outside [0, 1], ±inf at the edges), matching the previous behavior.dist_math.normal_lcdf/normal_lccdfare untouched — they are still used by TruncatedNormal, LogNormal, ExGaussian, OrderedProbit, etc.pytensor-distributions>=0.2.0(available on PyPI and conda-forge, noarch) torequirements.txtand all conda env files;requirements-dev.txtregenerated by thepip-from-condahook.Existing scipy-comparison tests (
TestMatchesScipy::test_normal,tests/logprob/test_abstract.pyincluding the logccdf graph and numerical-stability checks) cover the change; no new tests needed.Related Issue
Checklist
Type of change
🤖 Generated with Claude Code