Message-ID: <41AAE298.1050803@statistik.uni-dortmund.de>
Date: 2004-11-29T08:49:28Z
From: Uwe Ligges
Subject: hist and truehist
In-Reply-To: <41AAEB9B.7050902@bfro.uni-lj.si>
Gregor GORJANC wrote:
> Peter thanks for the response.
>
> So the results from hist(mydata) and truehist(mydata, h = .5) are the
> same. OK, but the sum of densities or intensities, for case that I gave,
> don't sum to 1 but to 2. Look bellow. I have an example where these
> density values are also up to 4 and sum to 5 (I have attached the PDF of
> that plot).
>
> This is really frustrating for me. What are actually these intensisties
> and densities, how are they calculated. Why are they the same?
>
> mydata <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,4,5)
> # histogram with frequencies
> hist(mydata)
> # histogram with ratios or probabilities
> hist(mydata, freq = F) # what are that values on vertical axis
> # lets take a look at values behind
> x <-hist(mydata, freq = F, plot = F); x
> # Sum values
> sum(x$intensities)
> [1] 2.000000
> R > sum(x$density)
> [1] 2.000000
Well, look at the breaks! Each has with 0.5!!!!
Hence the you have to calculate sum(x$density)*0.5
Uwe Ligges
> When I think of histogram (the one not with frequencies) I think of
> gathering records into "some classes" and then divide the number of
> records in each "class" by total number of all records. This is not the
> case in hist().
>
> Sorry for being pain in the ..., but this is really weird. Above that
> R-team is really doing a great job. Thanks for such a good tool!
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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