НачатьНачать бесплатно

Simulating draws from a binomial

In the last exercise, you simulated 10 separate coin flips, each with a 30% chance of heads. Thus, with rbinom(10, 1, .3) you ended up with 10 outcomes that were either 0 ("tails") or 1 ("heads").

But by changing the second argument of rbinom() (currently 1), you can flip multiple coins within each draw. Thus, each outcome will end up being a number between 0 and 10, showing the number of flips that were heads in that trial.

Это упражнение является частью курса

Foundations of Probability in R

Посмотреть курс

Инструкции к упражнению

  • Use the rbinom() function to simulate 100 separate occurrences of flipping 10 coins, where each coin has a 30% chance of coming up heads.
  • What kind of values do you see?

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Generate 100 occurrences of flipping 10 coins, each with 30% probability
Редактировать и запускать код