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 #51931 is a reply to message #51793] Fri, 08 December 2006 18:09 Go to previous messageGo to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
I was thinking the same thing. This never struck me as a histogram
problem. Sure, there are some novel uses for histogram, but this isn't
one of them. If the array needs to be sorted, and you need to retain
the original array, and you want one bin to have the low values and the
other to have the highs, then I can conceivably see a use for histogram
in this problem, but it would be so convoluted that it wouldn't be
worth it (you would still have to go through JD's process anyways).
The only difference I'm going to suggest is to allow for the situation
that I commented about:

t=randomu(seed, x)
t=t[sort(t)]
u=total(t, /cumulative)
bin1=t[where(u le u[x-1]/2.0)]
bin2=t[where(u gt u[x-1[/2.0)]

Braedley

JD Smith wrote:
> 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 06:53:54 PST 2025

Total time taken to generate the page: 2.24230 seconds