| Statistics Toolbox | ![]() |
Inverse of the discrete uniform cumulative distribution function.
Syntax
X = unidinv(P,N)
Description
X = unidinv(P,N)
returns the smallest positive integer X such that the discrete uniform cdf evaluated at X is equal to or exceeds P. You can think of P as the probability of drawing a number as large as X out of a hat with the numbers 1 through N inside.
Vector or matrix inputs for N and P must have the same size, which is also the size of X. A scalar input for N or P is expanded to a constant matrix with the same dimensions as the other input. The values in P must lie on the interval [0 1] and the values in N must be positive integers.
Examples
x = unidinv(0.7,20)
x =
14
y = unidinv(0.7 + eps,20)
y =
15
A small change in the first parameter produces a large jump in output. The cdf and its inverse are both step functions. The example shows what happens at a step.
See Also
icdf, unidcdf, unidpdf, unidrnd, unidstat
| unidcdf | unidpdf | ![]() |