code: public static long posOfPhi(final double phi, final long n) {
      final long pos = (long) Math.floor(phi * n);
      return (pos == n) ? n - 1 : pos;
    }
docs: Returns the zero-based index (position) of a value in the hypothetical sorted stream of
  values of size n.
  @param phi the fractional position where: 0 &le; &#966; &le; 1.0.
  @param n the size of the stream
  @return the index, a value between 0 and n-1.