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

Home » Public Forums » archive » What's HISTOGRAM doing now?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
What's HISTOGRAM doing now? [message #73100] Fri, 22 October 2010 02:36
Mrunmayee is currently offline  Mrunmayee
Messages: 24
Registered: May 2009
Junior Member
I just wanted logarithmic bins and opted to histogram the log of data.
Since that gave me some discrepancy, I wrote a tester code:

PRO Loghist_Test

data = 1. + Randomu(seed,1000)

nbins = 10
Max = 2.
Min = 1.

;Linear:
binsize = (Max - Min)/(Nbins-1)
datahist = Histogram(data, Min=Min, Max=Max, locations=bins,
binsize=binsize, omax=omax)
Print, "Binsize = ",binsize
Print, "Bins used: ", bins
Print, "Max value used = ", omax

;Logarithmic
binsize = (Alog10(Max) - Alog10(Min))/(Nbins-1)
datahistlog = Histogram(Alog10(data), Min=0, Max=Alog10(Max),
locations=bins, binsize=binsize, omax=omax)
Print, "Binsize = ",binsize
Print, "Bins used: ", bins
Print, "Max value used = ", omax
END

I ran this code, here is the output:
IDL> loghist_test
Binsize = 0.111111
Bins used: 1.00000 1.11111 1.22222 1.33333
1.44444 1.55556 1.66667 1.77778 1.88889
Max value used = 2.00000
Binsize = 0.0334478
Bins used: 0.00000 0.0334478 0.0668956 0.100343
0.133791 0.167239 0.200687 0.234134 0.267582
Max value used = 0.301030

Instead, if I do this directly from command line, i.e. for linear
bins,
IDL> datahist = histogram(data, min=1, max=2, binsize=0.111111,
locations=bins,omax=omax)
IDL> print,bins
1.00000 1.11111 1.22222 1.33333 1.44444
1.55555 1.66667 1.77778 1.88889 2.00000

Why are bins different? Output is unchaged for log bins when I am
histo-ing alog10(data) with corresponding log bins. Also, instead of
using BINSIZE, if I use NBINS in program, things work as they should.
So what's histogram upto NOW? Where am I missing something?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL Runtime
Next Topic: Re: Least Cost Path using Dijkstra's Algorithm

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

Current Time: Wed Oct 08 15:37:17 PDT 2025

Total time taken to generate the page: 0.00582 seconds