Python으로 배우는 Bayesian 데이터 분석
Michal Oleszak
Machine Learning Engineer




우리의 사전 믿음: 앞면이 덜 나옴

어떤 선택은 더 적합합니다!

numpy로 샘플링할 수 있습니다.get_heads_prob() 함수:def get_heads_prob(tosses):
num_heads = np.sum(tosses)
# prior: Beta(1,1)
return np.random.beta(num_heads + 1, len(tosses) - num_heads + 1, 1000)
시뮬레이션
numpy로 샘플링합니다:draws = np.random.beta(2, 4, 1000)
array([0.05941031, ..., 0.70015975])
sns.kdeplot(draws)
계산
head_prob posterior_prob
0 0.00 0.009901
1 0.01 0.003624
... ...
10199 0.99 0.003624
10200 1.00 0.009901
sns.lineplot(df["head_prob"], df["posterior_prob"])
Python으로 배우는 Bayesian 데이터 분석