Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import streamlit as st
|
|
| 3 |
import scipy.stats
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
from matplotlib import rc
|
| 6 |
-
plt.style.use('fivethirtyeight')
|
| 7 |
|
| 8 |
st.subheader("Bayesian Coin Toss")
|
| 9 |
st_col = st.columns(1)[0]
|
|
@@ -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')
|
| 35 |
-
axs.text(theta[3*N_theta//4], scipy.stats.beta.pdf(theta, alpha,beta)[3*N_theta//4],'Prior')
|
| 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')
|
| 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')
|
|
|
|
| 3 |
import scipy.stats
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
from matplotlib import rc
|
| 6 |
+
# plt.style.use('fivethirtyeight')
|
| 7 |
|
| 8 |
st.subheader("Bayesian Coin Toss")
|
| 9 |
st_col = st.columns(1)[0]
|
|
|
|
| 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=12)
|
| 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=10)
|
| 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')
|