Last bin of a histogram ? [message #83893] |
Wed, 10 April 2013 10:33 |
John Correira
Messages: 25 Registered: August 2011
|
Junior Member |
|
|
I'm trying to understand why HISTOGRAM selects the bins it does. The
final part I don't understand is the last bin. Here is an example
; some fake data
data = RANDOMU(systime(1),1000)*100
; make sure there are some values in the last bin
while N_ELEMENTS(where(data ge 99.5 AND data lt 100.,count)) do $
data = RANDOMU(systime(1),1000)*100
; how many points fall in the last bin?
print, count
h = histogram(data,min=9.5,max=99.5,binsize=.5,locations=locs)
nbins = n_elements(h)
; starting locations of the last few bins
print, locs[nbins-5:nbins-1]
; how many points in the last few bins
print, h[nbins-5:nbins-1]
Why is the last bin returned by the HISTOGRAM function zero? According
to the help, the LOCATIONS keyword returns "the starting locations for
each bin", so to my mind the last bin should include values that fall
between locations[-1] and locations[-1]+binsize. I must be missing
something obvious but I can't see it.
Best regards,
John
|
|
|