Closed bob-carpenter closed 4 years ago
If it's okay with you all, I'd like to take this on as my intro-to-stan-dev project. It might take a while in between job market prep so let me know if it's urgent + someone else would like to push on it.
Thanks, @shoshievass. I had also mentioned this issue to @rayleigh as something he might work on.
As I mentioned in writing up the issue, there are two ways to go here: (1) write a templated implementation that just follows the algorithm I wrote in Stan, or (2) write a version with analytic gradients for reverse mode. For (1), you could start with the output from the Stan compiler---you can look at the C++ class generated for the Stan code implementing the lpmf.
You could also do (1) and then later replace with (2). Either way, all the relevant tests will have to be written. The best thing to read on Stan's reverse-mode autodiff framework is the arXiv paper.
It’s all yours! If you need help, post on discourse.
On Thu, Jun 21 2018 at 4:42 PM, notifications@github.com wrote:
If it's okay with you all, I'd like to take this on as my intro-to-stan-dev project. It might take a while in between job market prep so let me know if it's urgent + someone else would like to push on it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/math/issues/869#issuecomment-399237051, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZ_F1Km4TY9FAF6Zxzip31Wv7a6K5l2ks5t_AVHgaJpZM4UJAH6 .
Just curious - has any progress been made on this? I have a problem I'm working on that I think would be appropriate to model with a poisson-binomial distribution.
Not that I kow of. We just kicked off another project with @shoshievass, so maybe it'll come up again.
Hello, I would love to help contributing to Stan and found this issue as "good first issue". If you are interested I could have a look into this? Cheers, Simon
Totally fine on my end!
-Shosh On Jun 7, 2020, 12:05 PM -0700, Simon Dirmeier notifications@github.com, wrote:
Hello, I would love to help contributing to Stan and found this issue as "good first issue". If you are interested I could have a look into this? Cheers, Simon — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Cool, I'll give it a try
Feel free to comment here if you have any questions about adding distributions/functions, always good to have more contributors on board!
You don't have to specify the gradients if you don't want to (although it can help with performance). If you just write the function to return the right log-probability, Stan's autodiff will take care of figuring out the gradients (this is how the ordered probit distribution is coded, for example).
If you do want to calculate the gradients, you want to code it so that the calculations are only done in cases where the gradients are actually needed. The if (!is_constant_all<T_prob>::value)
block is specifying that the gradients should only be calculated when the input variable is a type that contains gradient information (i.e., a var
or fvar
)
Closed via https://github.com/stan-dev/math/pull/1938
Summary:
Provide full implementation of Poisson-binomial for inclusion in Stan.
Description:
See the algorithm discussion on Discourse and Wikipedia article.
Analytic gradients would be a bonus, but a templated dynamic programming algorithm is a reasonable place to start.