เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

More updating with priors

Suppose we see 16 heads out of 20 flips, which would normally be strong evidence that the coin is biased. However, suppose we had set a prior probability of a 99% chance that the coin is fair (50% chance of heads), and only a 1% chance that the coin is biased (75% chance of heads).

You'll solve this exercise by finding the exact answer with dbinom() and Bayes' theorem. Recall that Bayes' theorem looks like:

$$\Pr(\mbox{fair}|A)=\frac{\Pr(A|\mbox{fair})\Pr(\mbox{fair})}{\Pr(A|\mbox{fair})\Pr(\mbox{fair})+\Pr(A|\mbox{biased})\Pr(\mbox{biased})}$$

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Foundations of Probability in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Use dbinom() to calculate the probabilities that a fair coin and a biased coin would result in 16 heads out of 20 flips.
  • Use Bayes' theorem to find the posterior probability that the coin is fair, given that there is a 99% prior probability that the coin is fair.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Use dbinom to find the probability of 16/20 from a fair or biased coin
probability_16_fair <-
probability_16_biased <-

# Use Bayes' theorem to find the posterior probability that the coin is fair
แก้ไขและรันโค้ด