code: public int getCompoundIndex(int first, int second) {
          if (first >= second) {
              throw new IllegalArgumentException("first (" + first + ") and second (" + second
                      + ") sample indexes, must comply with: 0 <= first < second");
          }
          return (second*second - second)/2 + first;
  
      }
docs: j
  /_0__1__2__3__4_
  i 0| -  0  1  3  6 |
  1|    -  2  4  7 |
  2|       -  5  8 |
  3|          -  9 |
  4|             - |
  
  `(j*(j-1)) / 2` is the amount of numbers in the triangular matrix before the column `j`.
  
  for example, with i=2, j=4:
  (j*(j-1)) / 2 == 6;
  6+i == 8