Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,8 +8,8 @@ from matplotlib import rc
|
|
| 8 |
st.subheader("Bayesian Coin Toss")
|
| 9 |
st_col = st.columns(1)[0]
|
| 10 |
|
| 11 |
-
N = st.slider('N_samples', min_value=2, max_value=20, value=
|
| 12 |
-
h = st.slider('N_heads', min_value=2, max_value=20, value=
|
| 13 |
alpha = st.slider('Alpha', min_value=0.5, max_value=5.0, value=2.0, step=0.1)
|
| 14 |
beta = st.slider('Beta', min_value=0.5, max_value=5.0, value=2.0, step=0.1)
|
| 15 |
|
|
@@ -31,10 +31,10 @@ ax.set_xlabel('p(head)');
|
|
| 31 |
# axs.text(h/N,2,'MLE', color='b')
|
| 32 |
|
| 33 |
axs.plot(theta, [scipy.stats.beta.pdf(t, h+alpha, N-h+beta) for t in theta], color='r')
|
| 34 |
-
ax.text(theta[N_theta//4], Likelihood[N_theta//4], 'Likelihood', color='b',zorder=
|
| 35 |
axs.text(theta[3*N_theta//4], scipy.stats.beta.pdf(theta, alpha,beta)[3*N_theta//4],'Prior',zorder=11)
|
| 36 |
# axs.text(alpha/(alpha+beta)-0.1,1,'Prior mean')
|
| 37 |
-
axs.text(theta[N_theta//2],scipy.stats.beta.pdf(theta[N_theta//2], h+alpha, N-h+beta),'Posterior',color='r',zorder=
|
| 38 |
# axs.text((h+alpha)/(N+alpha+beta)-0.1,3,'Post. Mean',color='r')
|
| 39 |
# ax.vlines(alpha/(alpha+beta), *ax.get_ylim(), linestyle='--',label='Prior mean',color='k')
|
| 40 |
# ax.vlines((h+alpha)/(N+alpha+beta), *ax.get_ylim(), linestyle='--',label='Post. Mean',color='r')
|
|
|
|
| 8 |
st.subheader("Bayesian Coin Toss")
|
| 9 |
st_col = st.columns(1)[0]
|
| 10 |
|
| 11 |
+
N = st.slider('N_samples', min_value=2, max_value=20, value=5, step=1)
|
| 12 |
+
h = st.slider('N_heads', min_value=2, max_value=20, value=4, step=1)
|
| 13 |
alpha = st.slider('Alpha', min_value=0.5, max_value=5.0, value=2.0, step=0.1)
|
| 14 |
beta = st.slider('Beta', min_value=0.5, max_value=5.0, value=2.0, step=0.1)
|
| 15 |
|
|
|
|
| 31 |
# axs.text(h/N,2,'MLE', color='b')
|
| 32 |
|
| 33 |
axs.plot(theta, [scipy.stats.beta.pdf(t, h+alpha, N-h+beta) for t in theta], color='r')
|
| 34 |
+
ax.text(theta[N_theta//4], Likelihood[N_theta//4], 'Likelihood', color='b',zorder=10)
|
| 35 |
axs.text(theta[3*N_theta//4], scipy.stats.beta.pdf(theta, alpha,beta)[3*N_theta//4],'Prior',zorder=11)
|
| 36 |
# axs.text(alpha/(alpha+beta)-0.1,1,'Prior mean')
|
| 37 |
+
axs.text(theta[N_theta//2],scipy.stats.beta.pdf(theta[N_theta//2], h+alpha, N-h+beta),'Posterior',color='r',zorder=12)
|
| 38 |
# axs.text((h+alpha)/(N+alpha+beta)-0.1,3,'Post. Mean',color='r')
|
| 39 |
# ax.vlines(alpha/(alpha+beta), *ax.get_ylim(), linestyle='--',label='Prior mean',color='k')
|
| 40 |
# ax.vlines((h+alpha)/(N+alpha+beta), *ax.get_ylim(), linestyle='--',label='Post. Mean',color='r')
|