開始使用免費開始

將模型改為使用具資訊性的先驗

畫面中顯示的是你在第 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))
編輯並執行程式碼