Thread View: net.math.stat
1 messages
1 total messages
Started by Rolf Turner
Thu, 26 Sep 1985 07:28
The function 'hist' in S.
Author: Rolf Turner
Date: Thu, 26 Sep 1985 07:28
Date: Thu, 26 Sep 1985 07:28
54 lines
2437 bytes
2437 bytes
I've noticed that the hist function in S does something which
seems wrong to me. When the argument 'scale' is TRUE, the
write-up says that hist produces counts on a "density scale".
It seems to me that if you're using the word "density" this
should imply that the histogram integrates to 1. Instead,
hist produces counts that SUM to 1. (However the i-th count
is NOT the estimated probability of an observation lying in the
i-th interval.
Explicitly
c(i)
count(i) = -----------------
sum c(j)
j
where
n(i)/n
c(i) = -----------------, n = sum n(j), w = sum w(j) .
w(i)/w j j
Observe that the denominators n and w cancel in the final count, and so are
irrelevant. (Note: n(i) is the i-th count; w(i) is the width of the i-th
interval.)
I've decided to replace the old count(i)'s by the more sensible
n(i)
h(i) = -----------------
n*w(i)
so that the integral of the histogram, = sum h(j)*w(j), is one.
j
Moreover, the area of the i-th rectangle, h(i)*w(i), is now the estimated
probability of an observation lying in the i-th interval.
Observe that the old
h(i)
count(i) = -------------------
sum h(j)
j
The change was made by modifying the subroutine hhcntz, in hhcntz.r,
by replacing the "if (idens)" clause by the following:
if (idens) { # change count into density if requested
sumc = 0.
do i = 1,nclass { sumc = sumc+class(i) }
do i = 1,nclass {
class(i) = class(i)/(sumc*(cbreak(i+1)-cbreak(i)))
}
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads