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

Home » Public Forums » archive » Histogram and bin sizes
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 bin sizes [message #58852 is a reply to message #58784] Fri, 22 February 2008 05:51 Go to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Feb 21, 5:54 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article
> < f6219865-59f4-4bf8-8718-67884c9df...@64g2000hsw.googlegroups .com >,
>
>
>
> Conor <cmanc...@gmail.com> wrote:
>> Arbitrary bin sizes should be pretty easy to program. You just need
>> to map your data points appropriately. For instance if you had the
>> data set:
>
>> x = randomu(seed,100)
>
>> and you wanted bins from:
>> [0-.1,.1-.3,.3-.35,.35-.8,.8-1]
>
>> you might do something like this:
>
>> x = randomu(seed,100)
>> bins = [ [0,.1], [.1,.3], [.3,.35], [.35,.8], [.8,1] ]
>> newx = fltarr(n_elements(x))
>> for i=0,n_elements(bins[0,*])-1 do begin
>> w = where( x ge bins[0,i] and x lt bins[1,i], c )
>> if c gt 0 then newx[w] = i+.5
>> endfor
>
>> hist = histogram(newx,binsize=1.0,min=0)
>> plothist,newx
>
> This will work, but will be extremely slow because you test every value
> in the input array once for every bin.
>
> The VALUE_LOCATE approach will be much faster, particularly for large
> numbers of bins, as it does a binary search.
>
> Ken Bowman

Oh fancy! I like it.
[Message index]
 
Read Message
Read Message
Previous Topic: Re: How to compare two vectors?
Next Topic: Configuring XPrinter

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

Current Time: Sat Oct 11 21:39:39 PDT 2025

Total time taken to generate the page: 2.48107 seconds