docs: function discInvCdf(min, max, x, p, f) {
           var incr;
  
           if (p === 0) { return min; }
           if (p === 1) { return max; }
           if (x > max) { x = max; }
           if (x < min) { x = min; }
  
           incr = Math.min(x - min, max - x);
           incr = Math.max(Math.floor(0.001 * incr), 1);
           while (incr > 1) {
              if (f(x) < p) { // x is too small
                 x += incr;
                 if (f(x) >= p) {
                    incr = Math.floor(incr / 2);
                 }
              } else {
                 // x is probably too large
                 x -= incr;
                 if (f(x) < p) {
                    incr = Math.floor(incr / 2);
                 }
              }
           }
           if (x < min) { x = min; }
           if (x > max) { x = max; }
           // incr is 1
           /* eslint-disable no-constant-condition */
           while (true) {
              if (x === min) {
                 if (f(x) >= p || utils.relativelyCloseTo(f(x), p, 1e-14)) { return x; }
                 x += 1;  // go right
              } else if (f(x - 1) >= p ||
                 utils.relativelyCloseTo(f(x - 1), p, 1e-14)) {
                 if (Math.abs(f(x) - p) < Math.abs(f(x - 1) - p)) {
                    return x;  // don't go left, x is better!
                 }
                 x -= 1; // go left
              } else {
                 // return x, or go right?
                 if (x === max || f(x) >= p || utils.relativelyCloseTo(f(x), p, 1e-14)) {
                    return x;
                 }
                 x += 1;  // go right
              }
           }
           /* eslint-enable no-constant-condition */
        }