How to draw a standard normal distribution in R

Possible duplicate:
Creating a standard normal distribution in R

Using R, draw a standard normal distribution. Indicate the mean and 3 standard deviations above and below the mean (10). Include an informative name and labels on the x and y axis.

This is a home problem. I am not sure how to go with the code. How do i get started?

+6
source share
3 answers

I am sure this is a duplicate . Anyway, look at the following code snippet

x <- seq(5, 15, length=1000) y <- dnorm(x, mean=10, sd=3) plot(x, y, type="l", lwd=1) 

Iā€™m sure that you can do it yourself, because the title, which you might want to find in the names main= and y-axis , is also up to you.

If you want to see more tails of the distribution, why don't you try playing with the seq(5, 15, ) section? Finally, if you want to know more about what dnorm does, I suggest you look here

+12
source

By the way, instead of generating x and y coordinates, you can also use the curve() function, which is designed to draw curves corresponding to the function (for example, the density of a standard normal function).

cm

 help(curve) 

and its examples.

And if you want to add som text to correctly mark the mean and standard deviations, you can use the text() function (see also plotmath , for annotations with mathematical symbols).

cm

 help(text) help(plotmath) 
+7
source

Is something like this possible?

 x<-rnorm(100000,mean=10, sd=2) hist(x,breaks=150,xlim=c(0,20),freq=FALSE) abline(v=10, lwd=5) abline(v=c(4,6,8,12,14,16), lwd=3,lty=3) 
+4
source

Source: https://habr.com/ru/post/915453/


All Articles