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 #51921 is a reply to message #51793] Mon, 11 December 2006 07:49 Go to previous messageGo to previous message
Christopher Thom is currently offline  Christopher Thom
Messages: 66
Registered: October 2006
Member
Quoth JD Smith:

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

aha! I wasn't aware of the /cumulative flag to total(), despite some
searching. Thanks for the pointer.

cheers
chris
[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:39:56 PST 2025

Total time taken to generate the page: 0.79977 seconds