Histograms with logarithmic x scale (LogHist and LogHistBins)

Hi,

currently I am using Igor Pro 7.08 and the procedure Log Histogram.ipf version 3.0. When using the two functions LogHist and LogHistBins I realized that they are not doing there work as they should do. Since programming this function should not be too difficult, I am wondering whether I am missing something, therefore let us consider the following simple case:

I have a distribution of some values [1,5,6,8,15,56,169] and want to create a histogram with a logarithmic x scale and a "logarithmically varying" bin size. Bin size shall be same as decades to keep it simple, i.e. 1-10^1, 10^1-10^2, 10^2-10^3, ...

Now just by looking you see that the histogram y values should be the following: [4, 2, 1, 0, 0, ...].

LogHistBin(test_values, 1, 1000, 3) gives me [1, 4, 2]  (LogHistBins(wave, startValue, endValue, binNumbers))

LogHist(test_values, 3, 1, 1) gives me [1, 2, 0, 0]  (LogHist(wave, decadesNumber, startValue, binsPerDecade))

First of all, none of the above functions provide me with the outcome I expected. Secondly, although those two are different functions, they should provide the same results when same conditions are provided, but they don´t. I am quite confused and could not find an answer to this. Am I missing something here?

You're right- there was a bug. Apparently sometime in the past 25 years something in Igor changed. In the function DoLogHist(), this line

		pp = (log(sw[pt]) - logStartX) / logDeltaX

needs to be

        pp = floor((log(sw[pt]) - logStartX) / logDeltaX)

I have made that change to the file that ships with Igor, but it won't get out until the next release, probably only for the Igor 9 beta. You can change your file, though. To make a WaveMetrics Procedure editable, create the global variable V_AllowProcEdits and set it to 1:

Variable root:V_allowProcEdits=1

Close the procedure file Log Histogram.ipf and recompile. That will bring it back but now the lock icon in the lower left corner of the window will be a crossed-out pencil. Click it to un-cross out the pencil and you can now edit the file.

Warning: we make it purposely difficult to edit WaveMetrics Procedures files! This is a bug fix, otherwise if you want to make your own edits to a WaveMetrics Procedure file, you should make a copy, rename it, put in your own space and work on the copy.

In reply to by johnweeks

Hi John,

thank you for your quick reply. I tried to modify Log Histogram.ipf but somehow it does not work as you suggested. I created a global variable V_allowProcEdits=1. What do you mean by "closing" file Log Histogram.ipf? I could only "hide" or "kill" the procedure. And I can only compile a procedure window which was edited already, but since I cannot edit Log Histogram.ipf, I cannot compile anything here. Could you explain this step in more detail, please?

By "closing" John meant "kill".

I'm not sure about V_allowProcEdits but you can edit the file like this:

1. Comment out your "#include <Log Histogram>" statement and compile procedures.

The Log Histogram file will be killed if it was opened by #include.

2. Choose Help->Show Igor Pro Folder.

3. In the desktop, open the "WaveMetrics Procedures/Analysis" folder in your Igor Pro folder.

4. Drag the "Log Histogram.ipf" file from the Analysis folder into Igor Pro to open it as a procedure file.

5. Edit the file as John showed above.

6. Choose File->Save Procedure to save the edited file.

7. Kill the "Log Histogram.ipf" window to close the file and delete the window.

8. Uncomment your "#include <Log Histogram>" statement.

9. Choose" Windows->Procedure Windows->Log Histogram.ifp" and verify that your edit is there.

 

Hi Howard,

thank you for your explanation. This helped me to correct the error. Now "LogHistBins()" is doing its work correctly. However LogHist() is still not working properly. Since I am only using "LogHistBins()", the case is solved for me.

What isn't working about LogHist()? If there is still a problem, I'd like to know so that I can fix it.

Using your example, I did this:

•LogHist("junk", 3, 0, 1)
print junk_hy
  junk_hy[0]= {4,2,1,0}
print junk_hx
  junk_hx[0]= {1,10,100,1000}

I think that's the expected output. The inputs to LogHist() are the name of the input wave (as a string because the procedure file is very old), the number of decades, the starting decade as log(start), and the number of bins per decade.