Dear All I would like to draw a picture with the density curve of a normal distribution over a histogram of a set of random numbers extracted from the same normal distribution. Is that possible? Thanks in advance, Paul
Density curve over a histogram
6 messages · Achim Zeileis, Uwe Ligges, Vincent Goulet +2 more
On Wed, 27 Apr 2005 19:06:07 +0100 Paul Smith wrote:
Dear All I would like to draw a picture with the density curve of a normal distribution over a histogram of a set of random numbers extracted from the same normal distribution. Is that possible?
To quote Simon `Yoda' Blomberg: "This is R. There is no if. Only how."
(see fortune("Yoda"))
Try:
R> x <- rnorm(100)
R> hist(x, freq = FALSE)
R> curve(dnorm, col = 2, add = TRUE)
Z
Thanks in advance, Paul
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Paul Smith wrote:
Dear All I would like to draw a picture with the density curve of a normal distribution over a histogram of a set of random numbers extracted from the same normal distribution. Is that possible?
Yes. If you like to know how, see e.g. ?hist and ?curve. Uew Ligges
Thanks in advance, Paul
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Le 27 Avril 2005 14:06, Paul Smith a ??crit??:
I would like to draw a picture with the density curve of a normal distribution over a histogram of a set of random numbers extracted from the same normal distribution. Is that possible?
Sure. See curve() with add=TRUE. Don't forget to use prob=TRUE when plotting your histogram, though. Vincent
On 4/27/05, Achim Zeileis <Achim.Zeileis at wu-wien.ac.at> wrote:
I would like to draw a picture with the density curve of a normal distribution over a histogram of a set of random numbers extracted from the same normal distribution. Is that possible?
To quote Simon `Yoda' Blomberg: "This is R. There is no if. Only how."
(see fortune("Yoda"))
Try:
R> x <- rnorm(100)
R> hist(x, freq = FALSE)
R> curve(dnorm, col = 2, add = TRUE)
Fantastic! Thanks a lot, Achim. Paul
Paul Smith <phhs80 at gmail.com> writes:
Dear All I would like to draw a picture with the density curve of a normal distribution over a histogram of a set of random numbers extracted from the same normal distribution. Is that possible?
Yes. If you look at the scripts that go with the ISwR package, you'll find a detailed example in ch01.R (end of 1.3/beginning of 1.4). Or you could read the book, of course...
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907