## Histogram with variable bin width

provat
Posts: 2
Joined: 2017-05-28
Location: United States

I know Igor has the function for making a histogram with an evenly spaced bin width. Is there any function for making a histogram with variable bin width?
For example, I have a data set (1000 points) that range over 1 to 20. I want to make a histogram of these data set using user-defined variable bin width. For example,
bin1 x<5, bin2 515 (something like that).

Thanks
PS

PKS

HJDrescher
Posts: 357
Joined: 2015-01-20
Location: Germany

I think the is no built-in function (since the result is a single wave). However, use the histogram function with a small (commensurate) bin size and collect the bins afterwards to your need. Create an x-wave corresponding to the new bins and you are done...
HJ

Posts: 810
Joined: 2007-06-29
Location: United States

If you are using IP7 you may consider a tricky approach by using JointHistogram, an operation that does allow you to provide your own bins wave. With JointHistogram duplicate your data wave (we will consider it to be the X wave) to create a fake Y wave and set it equal to 1 (or some other constant). You would then use the flag /XBWV to specify your bins wave for the X wave (the only one you are interested in). Since your Y wave is a constant, the Y distribution should not matter. Here is an example:

```•make /n=100 xxx=enoise(10)
•// create bins wave:
•make /N=5 xBins={1,3,5,7,10}
•duplicate xxx,yyy
•yyy=1
•jointhistogram /xbwv=xbins xxx,yyy
MatrixOP/O hist1DResult=col(M_JointHistogram,0)```

A.G.
WaveMetrics, Inc.

provat
Posts: 2
Joined: 2017-05-28
Location: United States

I am using IP 6.37. so jointhistogram option doesn't work for me :(

Posts: 810
Joined: 2007-06-29
Location: United States

IP7 has been out for almost a year now; time to upgrade!