comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Last bin of a histogram ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Last bin of a histogram ? [message #83885] Wed, 10 April 2013 11:20
John Correira is currently offline  John Correira
Messages: 25
Registered: August 2011
Junior Member
On 04/10/2013 02:08 PM, David Fanning wrote:
> John Correira writes:
>
>> I thought that defined the start of the last bin. If you look at the
>> output locations, the last one is 99.5, which, again according to the
>> help, defines the starting location for each bin.
>
> Well, OK, that is the starting location of the last bin, then. But, it
> will be empty, since you told the function to ignore anything that might
> go into it.
>
> Cheers,
>
> David
>

I see.

So the following two calls will return the exact same set of bins, but
different histograms:

h1 = histogram(data,min=0.,max=99.5,binsize=.5,locations=l1)
h2 = histogram(data,min=0.,nbins=200,binsize=.5,locations=l2)

print, array_equal(l1,l2)
print, array_equal(h1,h2)


Brilliant.
Re: Last bin of a histogram ? [message #83886 is a reply to message #83885] Wed, 10 April 2013 11:08 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
John Correira writes:

> I thought that defined the start of the last bin. If you look at the
> output locations, the last one is 99.5, which, again according to the
> help, defines the starting location for each bin.

Well, OK, that is the starting location of the last bin, then. But, it
will be empty, since you told the function to ignore anything that might
go into it.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Last bin of a histogram ? [message #83889 is a reply to message #83886] Wed, 10 April 2013 11:02 Go to previous message
John Correira is currently offline  John Correira
Messages: 25
Registered: August 2011
Junior Member
On 04/10/2013 01:50 PM, David Fanning wrote:
>
> It seems to me you are missing the fact that you set MAX=99.5 in the
> HISTOGRAM command. Or, am I missing something?
>
> Cheers,
>
> David
>

I thought that defined the start of the last bin. If you look at the
output locations, the last one is 99.5, which, again according to the
help, defines the starting location for each bin.

John
Re: Last bin of a histogram ? [message #83890 is a reply to message #83889] Wed, 10 April 2013 10:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
John Correira writes:

> 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.

It seems to me you are missing the fact that you set MAX=99.5 in the
HISTOGRAM command. Or, am I missing something?

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Are the JHU/APL/S1R libraries still available?
Next Topic: Coyote's Guide to Traditional IDL Graphics Almost Gone

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:57:23 PDT 2025

Total time taken to generate the page: 0.00427 seconds