Implement dims.DiracDelta - #8350
Conversation
DiracDeltaRV has no rng, so it can't be wrapped by the XRV machinery like the other scalar dims distributions. Build the regular RV and wrap it in an xtensor, relying on MeasurableXTensorFromTensor for the logp.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8350 +/- ##
==========================================
- Coverage 91.76% 91.73% -0.03%
==========================================
Files 128 128
Lines 20661 20697 +36
==========================================
+ Hits 18960 18987 +27
- Misses 1701 1710 +9
🚀 New features to boost your workflow:
|
| return super().dist([c], **kwargs) | ||
|
|
||
| @classmethod | ||
| def xrv_op(self, c, core_dims=None, extra_dims=None, rng=None, return_next_rng=False, **kwargs): |
There was a problem hiding this comment.
DiracDeltaRV has no rng, so this can't use as_xrv; here I wrap the tensor RV with xtensor_from_tensor and pass the rng through unchanged (same shape as the old Censored hack). Once DimSymbolicRandomVariable from #8346 lands, this should become a DimDiracDeltaRV(DimSymbolicRandomVariable) for consistency. Keep the interim wrapper until then?
ricardoV94
left a comment
There was a problem hiding this comment.
Looks good, just a nit to keep the tests light, we already have assert_equivalent_random_graph that should give us the guarantees we need that forward sampling will work
assert_equivalent_random_graph already guarantees forward sampling matches pm.DiracDelta, so the explicit sample_prior_predictive test is not needed.
|
Thanks @anevolbap |
Related to #7874
Needed for the pymc-marketing Bass model migration to
pymc.dims(pymc-labs/pymc-marketing#2598).DiracDeltais the only distribution that migration uses thatpymc.dimswas missing.Also adds
PoissonandNegativeBinomialto the dims distributions API page.