Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,8 @@ from matplotlib import rc
|
|
| 7 |
st.subheader("Bayesian Coin Toss")
|
| 8 |
st_col = st.columns(1)[0]
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
alpha = st.slider('Alpha', 0.5, 5.0, 0.5)
|
| 13 |
beta = st.slider('Beta', 0.5, 5.0, 0.5)
|
| 14 |
|
|
@@ -22,8 +22,6 @@ def Bernoulli(theta, N, h):
|
|
| 22 |
return (theta ** h) * ((1-theta) ** (N-h))
|
| 23 |
|
| 24 |
Likelihood = [Bernoulli(t,N,h) for t in theta]
|
| 25 |
-
|
| 26 |
-
ax.cla();axs.cla()
|
| 27 |
ax.plot(theta, Likelihood, label='Likelihood',color='b');
|
| 28 |
axs.plot(theta, scipy.stats.beta.pdf(theta, alpha,beta), label='Prior',color='k');
|
| 29 |
ax.set_xlabel('p(head)');
|
|
@@ -44,6 +42,9 @@ axs.tick_params(axis='y', colors='r')
|
|
| 44 |
ax.set_ylabel('Likelihood',color='b')
|
| 45 |
axs.set_ylabel('Prior/Posterior', color='r', rotation=270, labelpad=30)
|
| 46 |
|
|
|
|
|
|
|
|
|
|
| 47 |
with st_col:
|
| 48 |
st.pyplot(fig)
|
| 49 |
|
|
|
|
| 7 |
st.subheader("Bayesian Coin Toss")
|
| 8 |
st_col = st.columns(1)[0]
|
| 9 |
|
| 10 |
+
N = st.slider('N_samples', 2, 40, 1)
|
| 11 |
+
h = st.slider('N_heads', 2, 40, 1)
|
| 12 |
alpha = st.slider('Alpha', 0.5, 5.0, 0.5)
|
| 13 |
beta = st.slider('Beta', 0.5, 5.0, 0.5)
|
| 14 |
|
|
|
|
| 22 |
return (theta ** h) * ((1-theta) ** (N-h))
|
| 23 |
|
| 24 |
Likelihood = [Bernoulli(t,N,h) for t in theta]
|
|
|
|
|
|
|
| 25 |
ax.plot(theta, Likelihood, label='Likelihood',color='b');
|
| 26 |
axs.plot(theta, scipy.stats.beta.pdf(theta, alpha,beta), label='Prior',color='k');
|
| 27 |
ax.set_xlabel('p(head)');
|
|
|
|
| 42 |
ax.set_ylabel('Likelihood',color='b')
|
| 43 |
axs.set_ylabel('Prior/Posterior', color='r', rotation=270, labelpad=30)
|
| 44 |
|
| 45 |
+
ax.spines['top'].set_visible(False)
|
| 46 |
+
axs.spines['top'].set_visible(False)
|
| 47 |
+
|
| 48 |
with st_col:
|
| 49 |
st.pyplot(fig)
|
| 50 |
|