Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 289

Illustrating the Normal Distribution

Оглавление

In the following example we generate data with the random generator function rnorm() and then compare the histogramof that data with the ideal probability density function of the Normal distribution. The output of the following code is Figure 8.1 on this page.


Figure 8.1: A comparison between a set of random numbers drawn from the normal distribution (khaki) and the theoretical shape of the normal distribution in blue.

obs <- rnorm(600,10,3) hist(obs,col=“khaki3”,freq=FALSE) x <- seq(from=,to=20,by=0.001) lines(x, dnorm(x,10,3),col=“blue”,lwd=4)

The Big R-Book

Подняться наверх