CommencerCommencer gratuitement

Simulating from a Poisson and a binomial

If we were flipping 100,000 coins that each have a .2% chance of coming up heads, you could use a Poisson(2) distribution to approximate it. Let's check that through simulation.

Cet exercice fait partie du cours

Foundations of Probability in R

Afficher le cours

Instructions

  • Generate 100,000 draws from the Binomial(1000, .002) distribution. Save it as binom_sample.
  • Generate 100,000 draws from the Poisson distribution that approximates this binomial distribution, using the rpois() function. Save it as poisson_sample.
  • Compare the two distributions with the compare_histograms() function. (Remember that this takes two arguments: the two samples that are to be compared).

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Draw a random sample of 100,000 from the Binomial(1000, .002) distribution
binom_sample <- 

# Draw a random sample of 100,000 from the Poisson approximation
poisson_sample <- 

# Compare the two distributions with the compare_histograms function
Modifier et exécuter le code