शुरू करेंमुफ़्त में शुरू करें

Updating with simulation after 16 heads

We see 16 out of 20 flips from a coin that is either fair (50% chance of heads) or biased (75% chance of heads). How likely is it that the coin is fair?

यह अभ्यास पाठ्यक्रम का हिस्सा है

Foundations of Probability in R

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Simulate 50,000 cases of flipping 20 coins from a fair coin (50% chance of heads), as well as from a biased coin (75% chance of heads). Save these variables as fair and biased respectively.
  • Find the number of fair coins where exactly 16/20 came up heads, then the number of biased coins where exactly 16/20 came up heads. Save them as fair_16 and biased_16 respectively.
  • Print the fraction of all coins that came up heads 16 times that were fair coins- this is the posterior probability that a coin with 16/20 is fair.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Simulate 50000 cases of flipping 20 coins from fair and from biased
fair <- 
biased <- 

# How many fair cases, and how many biased, led to exactly 16 heads?
fair_16 <- 
biased_16 <- 

# Find the fraction of fair coins that are 16 out of all coins that were 16
कोड संपादित करें और चलाएँ