When finding the inverse of the cdf at p, and with the solution between low and high, this function narrows this range based on an intermediate discrete value, and zeroes-in on that discrete value if it's the solution.

narrow_by_discretes(distribution, p, low, high, discrete, direction)



A distribution having access to a cdf.


Value of the cdf to calculate inverse at.

low, high

Single numerics specifying the lower and upper bound to look between.


Numeric value indicating a discrete point to possibly narrow the range by. Could be NA; could have length 0; could be outside of the range c(low, high).


One of "left" for calculating left-inverse, or "right" for calculating right-inverse.


The benefit of this step when inverting a cdf is to return the exact discrete value if p falls within its jump discontinuity.