정보성 사전분포를 사용하도록 모델 바꾸기
표시된 코드는 2장에서 처음부터 직접 만든 이전 모델이에요.
이 연습은 강의의 일부입니다
R로 배우는 Bayesian 데이터 분석 기초
연습 안내
- 방금 선택한
proportion_clicks의 새로운 정보성 사전분포를 사용하도록 이 모델을 바꾸세요:
rbeta(n_draws, shape1 = 5, shape2 = 95)
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
n_draws <- 100000
n_ads_shown <- 100
# Change the prior on proportion_clicks
proportion_clicks <-
runif(n_draws, min = 0.0, max = 0.2)
n_visitors <-
rbinom(n_draws, size = n_ads_shown,
prob = proportion_clicks)
prior <-
data.frame(proportion_clicks, n_visitors)
posterior <-
prior[prior$n_visitors == 13, ]
# This plots the prior and the posterior in the same plot
par(mfcol = c(2, 1))
hist(prior$proportion_clicks,
xlim = c(0, 0.25))
hist(posterior$proportion_clicks,
xlim = c(0, 0.25))