Updating with Bayes theorem
In this chapter, you used simulation to estimate the posterior probability that a coin that resulted in 11 heads out of 20 is fair. Now you'll calculate it again, this time using the exact probabilities from dbinom(). There is a 50% chance the coin is fair and a 50% chance the coin is biased.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Foundations of Probability in R
अभ्यास निर्देश
- Use the
dbinom()function to calculate the exact probability of getting 11 heads out of 20 flips with a fair coin (50% chance of heads) and with a biased coin (75% chance of heads). Save them asprobability_fairandprobability_biased, respectively. - Use these to calculate the posterior probability that the coin is fair. This is the probability that you would get 11 from a fair coin, divided by the sum of the two probabilities.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Use dbinom to calculate the probability of 11/20 heads with fair or biased coin
probability_fair <-
probability_biased <-
# Calculate the posterior probability that the coin is fair