-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Firstly, thanks for the fantastic work here :)
Very helpful.
I was slightly confused about some code in Lesson 2 (Garden of Forking Data). In cell 16, Sampling from a Posterior Distribution, you show the beta distribution posterior using the below code:
a, b = 6, 3
# draw random samples from Beta PDF
beta_posterior_pdf = stats.beta(a, b)
beta_posterior_samples = beta_posterior_pdf.rvs(size=1000)
# Show that our beta postorior captures shape of beta-distributed samples
plt.hist(beta_posterior_samples, bins=50, density=True, label='samples');
probs = np.linspace(0, 1, 100)
plt.plot(probs, beta_posterior(a-1, b-1, probs), linewidth=3, color='k', linestyle='--', label='beta distribution')
plt.xlabel("proportion water")
plt.ylabel("density")
plt.legend();
I'm confused about the code for the dotted lines plot, why is it beta_posterior(a-1, b-1, probs) instead of beta_posterior(a, b, probs), could you add an explanation or link for it in the notebook if possible?
The code seems to be correct as in the line fits for the produced distribution but I can't figure out why the -1 is required for both a and b. Probably some way the arguments for the library are defined?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels