-
-
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
Unexpected behavior in random
#2909
Comments
I hope it doesnt effect |
A quick experiment says it does not: with pm.Model() as model:
a = pm.Uniform('a', lower=0, upper=1, shape=10)
b = pm.Binomial('b', n=1, p=a, shape=10, observed=np.ones(10))
trace = pm.sample(1000)
post = pm.sample_ppc(trace)
post['b'].mean(axis=0).std() # 0.0139301830569451
b.distribution.random(size=post['b'].shape[0]).mean(axis=0).std() # 0.2558969323770803 |
Sorry to jump in on this discussion not being a member but I think that what @ColCarroll pointed out should be considered a bug and should be fixed as he says by adding a Consider his first example. The current behavior of
In the end, if |
@ColCarroll I'd agree with @lucianopaz on this. There's a bug in draw_values |
Consider the following:
I would have expected this mean to be close to 0.5 for each element.
This is happening because the implementation for
.random
methods all follow this pattern:Note that a single value is drawn for
p
, and used in all draws for the random variable. Indeed, in the above example, the value drawn forp
was quite close to the mean of the draws!This is causing strange behavior in
sample_prior
(#2876). If this is considered a bug, I can fix it by allowingdraw_values
to have asize
argument. Otherwise I can change #2876 to work around the behavior.(NB: I think this does not effect any of the sampling procedures)
The text was updated successfully, but these errors were encountered: