[R] A somewhat off the line question to a log normal distrib
Karl Ove Hufthammer
karl at huftis.org
Thu Dec 2 14:43:40 CET 2004
2004-12-02 Robin Hankin wrote:
> hist(replicate(10000,f(10)))
>
> gives us a histogram of 10000 observations of a variable that is
> itself the mean of 10 exponential variables.
You might want to use 'truehist' from the 'MASS' package instead. It
draws a real histogram (where the area of the bars sum to 1), and the
number of bars increases with the number of observations.
Example:
library(MASS)
truehist(rnorm(100), col="wheat")
truehist(rnorm(1000), col="wheat")
truehist(rnorm(10000), col="wheat")
x = rnorm(100000)
truehist(x, col="wheat")
plot(density(x)) # Density estimate
(Regarding col="wheat": The default colour used by 'truehist' is
really eye-blinding ... :) )
--
Regards,
Karl Ove Hufthammer
More information about the R-help
mailing list