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

Home » Public Forums » archive » Histogram quickie
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 quickie [message #51935 is a reply to message #51793] Fri, 08 December 2006 14:38 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 08 Dec 2006 12:55:56 -0600, Christopher Thom wrote:

> Hi all,
>
> I'm a long time where() fan, but trying to learn to wield this histogram
> beast. I'm working on an algorithm, and would like a way to divide an
> array of values into two bins, such that the sum of each bin is roughly
> equal. The values have no fixed distribution, so I expect the bin sizes to
> be non-uniform.
>
> This sort of problem seems an ideal place to start earning my histogram
> badge, but I have to confess to only being able to think of
> brute-force-type solutions. Any suggestions?

Probably WHERE will serve you well:

IDL> t=total(a,/CUMULATIVE)
IDL> bin1=where(t lt t[n_elements(a)-1]/2,COMPLEMENT=bin2)

Of course, there are many ways to divide values such that they fall into
two roughly equal bins (n choose 2), some of which may be better than
others.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL with command line like input, (in EFTS -EUMETSAT)
Next Topic: Record keeping

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

Current Time: Wed Dec 03 07:40:06 PST 2025

Total time taken to generate the page: 1.68511 seconds