-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
WIP Implement ZeroInflatedPoisson as a subclass of Mixture #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Implement ZeroInflatedPoisson as a subclass of Mixture #1459
Conversation
An alternative would be to change the |
This would make |
That doesn't sound unreasonable. I suppose there's no way to get the broadcasting in |
Yes, I would remove those other implementations. Agreed that changing I have not been able to think of a way to get |
That's probably best then, both are hacks in a way, just one with less code. Adding a comment on why we're using switch here should help then also. |
Seems the broadcasting is merged now @AustinRochford can you check if this works with the new code that @fonnesbeck submitted recently. |
@AustinRochford Any progress here? Seems like the original zero-inflated-poisson is wrong. |
@twiecki nothing recently; there are a few things left to do. Unfortunately we have entered our busy holiday season at work, so it may take a while for me to get this into shape. |
ok, no worries obviously and thanks for the update. |
Putting this up for feedback, as it is not quite as straightforward as I would have liked.
Due to #1449 and its fix #1452, we can't use
ConstantDist
for the zero component, since it no longer broadcasts the way we need it to in this instance.More specifically, since #1452, if any of the elements of
pm.ConstantDist.dist(0).logp(value)
are non-zero, the result will be-np.inf
. TheZero
hack included below restores the pre-#1452 broadcasting behavior by bypassingbound
and usingtt.switch
directly. Using this hack,pm.Zero.dist().logp(value)
will be an array whose entries are zero when the corresponding entry invalue
is zero and-np.inf
when the corresponding entry invalue
is non-zero. The use oflogsumexp
inMixture
will gracefully handle these-np.inf
s, as desired.My question for other is if we want to use this
Zero
hack to implementZeroInflated
* distributions as subclasses ofMixture
or leave them as-is. Obviously we do not need to exportZero
to the global namespace.If we decide to go forward with this approach, I will port
ZeroInflatedNegativeBinomial
as well and fix any test that this might break.