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

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

Source Code: unidpdf

Example: 1

 

 ## 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 ("Descrete uniform PDF")
 xlabel ("values in x")
 ylabel ("density")

                    
plotted figure