This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Discrete uniform inverse cumulative distribution function


X = unidinv(P,N)


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.

P and N can be vectors, matrices, or multidimensional arrays that have the same size, which is also the size of X. A scalar input for N or P is expanded to a constant array 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.


x = unidinv(0.7,20)
x =

y = unidinv(0.7 + eps,20)
y =

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.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a

Was this topic helpful?