-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Difference in beta support between pymc3 and scipy results in error in sample_prior_predictive() #3898
Comments
Hi Zachary, |
Alpha and beta have to be > 0. The pdf of Beta contains Γ(α) and Γ(β). The gamma function is infinite at zero. |
Some parameterizations/transformations have support on the closed interval, but for ours it should be open. |
@fonnesbeck Shouldn't the beta only be 0 when α = β = 1? This is the definition in the doc page for And if x = 0, then x^{a - 1} can only be non-zero when a = 1. @zack-kimble 's example shows (and I checked this) that This is not sufficiently my thing that I don't feel confident reporting this to the scipy.stats project -- @zack-kimble would you do that? I also don't know what we should do about this. Writing a high performance RNG for betas using numpy is really not my thing, but if someone has one that doesn't have this pathology, I'd be happy to try to plug it in. Alternatively, should we just return |
When alpha and beta are 1, the beta distribution just becomes a uniform distribution. |
@fonnesbeck I have replicated this issue, though, and we can get x = 0 when alpha and beta are 0.1, which is definitely wrong. @zack-kimble We are using |
@zack-kimble, we've managed to identify that this is a problem caused by |
@lucianopaz, @rpgoldman Thanks for tracking it back to numpy and opening a PR there. Sorry I didn't follow up myself there earlier! |
After some discussion with the numpy devs, their random generator will remain as is, and we will clip the values of the samples it generates to lie in the open (0, 1) interval in pymc3. I hope to be able to open a PR tomorrow. |
Description of your problem
Please provide a minimal, self-contained, and reproducible example.
Please provide the full traceback.
Please provide any additional information below.
I am using beta as a hyperprior for other beta distributions and parameterizing based on mean and sample size. As a result, if the random variable from the hyper prior is 0 or 1, alpha or beta will end up 0, which is outside their domain. pymc3.Beta has support on (0,1), so I haven't seen an issue with sampling posteriors. When running sample_prior_predictive(), I get a domain error, which I believe is because scipy.stats.beta().rvs() will happily return 0 or 1.
Maybe this is just because of truncation in float64 (1 is far more common than 0), but I noticed the scipy.stats.beta documentation does state support on [0,1]. Not sure whether or not that makes it a scipy issue instead, but thought it was worth mentioning here.
Versions and main components
The text was updated successfully, but these errors were encountered: