Python으로 배우는 Bayesian 데이터 분석
Michal Oleszak
Machine Learning Engineer
100회 시행에서의 성공 횟수:
import numpy as np
np.random.binomial(100, 0.5)
51
np.random.binomial(100, 0.5)
44
이항분포에서 표본 추출:
import numpy as np
np.random.binomial(1, 0.5, size=5)
array([1, 0, 0, 1, 1])
get_heads_prob() - 사용자 정의 함수
import numpy as np
tosses = np.random.binomial(1, 0.5, size=1000)
print(tosses)
[1 0 0 0 1 1 0 1 1 ... ]
heads_prob = get_heads_prob(tosses)
print(heads_prob)
[0.47815295 0.51679212 0.51684779 ... ]
import matplotlib.pyplot as plt
import seaborn as sns
sns.kdeplot(heads_prob,
shade=True,
label="heads probabilty")
plt.show()

Python으로 배우는 Bayesian 데이터 분석