What's HISTOGRAM doing now? [message #73100] |
Fri, 22 October 2010 02:36 |
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?
|
|
|