-
Notifications
You must be signed in to change notification settings - Fork 26
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
proposal for mixture models #53
base: master
Are you sure you want to change the base?
Conversation
Thanks, @SteveBronder. Does it render automatically or did you have to do something to turn it on? |
Do you intend to support mixtures of distributions with different support (e.g. a mixture of a normal and a lognormal)? |
Yes. There's an example of zero-inflated Poisson that mix a distribution with support at a single point with a mixture with support over all natural numbers. Are there problems that arise in that setting we should consider? Even if there is, support isn't something that's known statically, so it'd have to be some kind of run-time check. |
If you pass a negative value to a lognormal_lpdf, I don't think you get back So I think you'd either need to wrap the input Edit: I think the example with the delta function on zero is an example of a function with support everywhere over the integers, and a return of Edit2: Maybe the exception is exactly the sort of runtime check you have in mind, and the solution is to force the user to define their own lpdf that implements the support check and branching logic. |
Good point about returning exceptions. So we'll have to warn people about that. Edit 1: Yes, that's right. We were torn when first building Stan between throwing exceptions and returning -inf for out of support args and went with the latter to make it easier for people to debug. Edit 2: No, I just hadn't thought this through. But that is what it will force the user to do. |
the mixture_lpdf function could catch std::invalid_argument and return -infinity? That seems a bit too magical though, and definitely harder to debug |
Do arguments arguments of invalid type result in std::invalid_argument, or something else? If the former then I think this is a no-go. |
Depends on what you mean by “type”. It would also be thrown for example if you give a matrix that isn’t a cholesky factor to wishart_cholesky_lpdf |
I mean would catching exceptions in this way allow people to end up passing integers to _lpdfs or reals to _lpmfs without seeing an exception raised? |
That kind of thing would be stopped by the compiler still. Invalid_argument is only used for runtime properties like bounds or requiring a matrix to be square |
@jsocolar noted in an offline discussion that we need to include truncation contributions to the densities, too. |
We also need a note about mixing pdfs and pmfs being illegal. You could wrap a pmf in a user-defined pdf, but Stan's not going to be able to handle sampling parameters that mix discrete and continuous distributions. |
Some citations from @avehtari: PyMC has pymc.Mixture: Turing.jl has MixtureModel: |
The feature proposal is in the file
0034-mixtures.md