[Rd] Problem with the 'hist' function
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Feb 15 00:14:27 CET 2007
On 2/14/2007 5:51 PM, Edo Airoldi wrote:
> Hi, I am using the following R version:
>
> > R version 2.4.1 (2006-12-18)
> > Copyright (C) 2006 The R Foundation for Statistical Computing
> > ISBN 3-900051-07-0
>
> I believe I found a bug in the 'hist' function, when
> 'probability=TRUE'. I looked in the archives and I came across
> problems with the 'hist' functions (e.g., bug PR# 944, posted in
> 2001), however, a quick search did not find the exact problem I a
> found. A brief description of the issue follows.
>
> > z<-rnorm(10)
> > z
> [1] 0.51649608 -0.20676010 0.65951365 0.46733006 0.02084361
> 0.18323525
> [7] -0.21522566 0.29597667 0.81549448 0.26252625
> > hist(z,breaks=seq(-1,1,by=.25))
> > hist(z,breaks=seq(-1,1,by=.25),probability=TRUE)
>
> I think the values on the Y axis are messed up, e.g., it should top
> at 0.3 (relative frequency) for the bin [0.25 0.50). How is 'Density'
> computed?
It's not relative frequency, it's density: relative frequency per unit
of x. The upper limit would be 4 with a step size of 0.25 (if all the
observations fell in one interval).
Duncan Murdoch
More information about the R-devel
mailing list