Categories &

Functions List

Function Reference: unidpdf

statistics: y = unidpdf (x, N)

Discrete uniform probability density function (PDF).

For each element of x, compute the probability density function (PDF) of the discrete uniform distribution with parameter N, which corresponds to the maximum observable value. unidpdf assumes the integer values in the range [1,N] with equal probability. The size of x is the common size of p and N. A scalar input functions as a constant matrix of the same size as the other inputs.

The maximum observable values in N must be positive integers, otherwise NaN is returned.

Warning: The underlying implementation uses the double class and will only be accurate for N < flintmax (2^{53} on IEEE 754 compatible systems).

Further information about the discrete uniform distribution can be found at https://en.wikipedia.org/wiki/Discrete_uniform_distribution

Input arguments must be double, single, or an integer type; logical and character arrays are rejected. Integer input is promoted to double, so the result is always a probability. MATLAB is inconsistent here: for several of the discrete distributions it returns the result in the integer class of the input, truncating a probability to 0 or 1.

See also: unidcdf, unidinv, unidrnd, unidfit, unidstat

Source Code: unidpdf

Plot various PDFs from the discrete uniform distribution

 x = 0:10;
 y1 = unidpdf (x, 5);
 y2 = unidpdf (x, 9);
 plot (x, y1, '*b', x, y2, '*g')
 grid on
 xlim ([0, 10])
 ylim ([0, 0.25])
 legend ({'N = 5', 'N = 9'}, 'location', 'northeast')
 title ('Discrete uniform PDF')
 xlabel ('values in x')
 ylabel ('density')
plotted figure