Skip to content
Prev 315886 / 398502 Next

density of hist(freq = FALSE) inversely affected by data magnitude

The probability density function is not unitless - it is the derivative of the
[cumulative] probability distribution function so it has units delta-probability-mass
over delta-x.  It must integrate to 1 (over the all possible x).  hist(freq=FALSE,x)
or hist(prob=TRUE,x) displays an estimate of the density function and the following
example shows how the scale matches what you get from the presumed 
population density function.
function (n, sd) 
{
    x <- rnorm(n, sd = sd)
    hist(x, freq = FALSE) # estimated density
    s <- seq(min(x), max(x), len = 129)
    lines(s, dnorm(s, sd = sd), col = "red") # overlay expected density for this sample
}
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com