Suppose that X is the array X=[1 0 1 2 0 4 2 0 4 1 4 1] We can compute the histogram with H=HISTOGRAM(X,MIN=0,MAX=4,REVERSE_INDICES=R) The min and max were set to the range of the data. Now print H H=[3 4 2 0 3] 0 1 2 3 4 Index The index is printed here for reference. The vector H tells us that: 0 occurs 3 times since H[0]=3, 1 occurs 4 times, since H[1]=4, and so on. The locations of the values for each cell are given in the reverse index vector, R. R=[ 6 9 13 15 15 18 1 4 7 0 2 9 11 3 6 5 8 10] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Index R[0]=6 tells us that the indexes for the zeros in the original X are listed beginning with position 6. R[1]=9 tells us that the indexes for the ones in the original X are listed beginning with position 9. R[2]=13 tells us that the indexes for the twos in the original X are listed beginning with position 13. R[3]=15 tells us that the indexes for the threes in the original X are listed beginning with position 15. R[4]=15 tells us that the indexes for the fours in the original X are listed beginning with position 15. R[5]=18 tells us that the indexes for the fives in the original X are listed beginning with position 18. Since 5 is greater than MAX, this is a dummy entry to help with the following calculations. If we were to print R[6:8] we would get the locations of the zeros in the X array. They are R[6:8]=[1,4,7]. Hence, Print,X[R[6:8]] produces the output [1,4,7]. But we need a way to fill in the "6" and the "8" automatically. We could do the following: i=0 k1=R[i] ;Yields k1=R[0]=6 k2=R[i+1]-1 ;Yields k2=R[1]-1=9-1=8 k3=R[k1:k2] ;Yields k3=R[6:8]=[1,4,7] Print,X[k3] ;Prints X[1,4,7]=[0,0,0] Hence, k3 contains the indexes you want for the locations of 0 in the X array. You can shorten this by collapsing some of the above statements: i=0 k3=R[R[i]:R[i+1]-1] ; The locations of 0 in X. To find the location of 1 in X we write: i=1 k3=R[R[i]:R[i+1]-1] You can do this for each value using i=0,1,2,3,4. Note that with i=4 the above gives i=4 k3=R[R[i]:R[i+1]-1]=R[R[4]:R[5]-1]=R[15:18-1]=R[15:17]=[5,8,10] We need R[5] in this formula, and the REVERSE_INDICES keyword provides it. You can use the indices that are returned in this way to find the locations of the values in any array.