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

Home » Public Forums » archive » Re: 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 #58863 is a reply to message #58772] Thu, 21 February 2008 14:54 Go to previous messageGo to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<f6219865-59f4-4bf8-8718-67884c9df226@64g2000hsw.googlegroups.com>,
Conor <cmancone@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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL 6.3 read_binary ??
Next Topic: Re: widget draw background color

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

Current Time: Sun Oct 12 00:51:26 PDT 2025

Total time taken to generate the page: 0.48107 seconds