ПочатиПочніть безкоштовно

Simulating from the binomial and the normal

In this exercise you'll see for yourself whether the normal is a reasonable approximation to the binomial by simulating large samples from the binomial distribution and its normal approximation and comparing their histograms.

Ця вправа є частиною курсу

Foundations of Probability in R

Переглянути курс

Інструкції до вправи

  • Generate 100,000 draws from the Binomial(1000, .2) distribution. Save this as binom_sample.
  • Generate 100,000 draws from the normal distribution that approximates this binomial distribution, using the rnorm() function. (Remember that rnorm() takes the mean and the standard deviation, which is the square root of the variance). Save this as normal_sample.
  • Compare the two distributions with the compare_histograms() function. (Remember that this takes two arguments: the first and second vectors to compare).

Інтерактивна практична вправа

Спробуйте виконати цю вправу, доповнивши цей зразок коду.

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

# Draw a random sample of 100,000 from the normal approximation
normal_sample <- 

# Compare the two distributions with the compare_histograms function
Редагувати та запускати код