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

Home » Public Forums » archive » Re: histogram and binsize problems
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: histogram and binsize problems [message #34245 is a reply to message #34239] Thu, 27 February 2003 12:00 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Chad Bender (cbender@mail.astro.sunysb.edu) writes:

> I tried a few other things to see if I could figure out something of what
> histogram is doing. It's obvious from something like the following that
> histogram has rounding issues at the bin boundaries.
> IDL> test=findgen(31)*0.005
> IDL> plot, test, histogram(test, min=0.0, max=0.15, binsize=0.005),
> psym=10
> IDL> plot, test, histogram(test, binsize=0.005), psym=10

Humm. I'm not sure that's what I would conclude from
this test.

This program seems to work correctly:

PRO TEST
data = randomu(-3L, 500)
data = scale_vector(data, 0.00, 0.14999999)
test = data
binsize = 0.005
histdata = histogram(test, min=min(data), $
max=max(data), binsize=binsize)
TVLCT, 0, 255, 0, !D.Table_Size-2
DEVICE, Decomposed=0
color = !D.Table_Size-2
npts = N_Elements(histdata)
halfbinsize = binsize / 2.0
bins = Findgen(N_Elements(histdata)) * binsize + Min(test)
binsToPlot = [bins[0], bins + halfbinsize, $
bins[npts-1] + binsize]
histdataToPlot = [histdata[0], histdata, histdata[npts-1]]
xrange = [Min(binsToPlot), Max(binsToPlot)]
Plot, binsToPlot, histdataToPlot, PSYM=10, /NoData
OPlot, binsToPlot, histdataToPlot, Color=color, PSYM=10
END

You will need SCALE_VECTOR from my web page to run it:

http://www.dfanning.com/programs/scale_vector.pro

I think if a value is greater than or equal to the
lower bin range, it goes in that bin. Seems reasonable
to me.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Is PDF the only help option in 5.6?
Next Topic: Matrix op speaks. Computer programmers needed to build matrix.

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

Current Time: Wed Oct 08 19:02:41 PDT 2025

Total time taken to generate the page: 0.00256 seconds