Categories &

Functions List

Function Reference: unifpdf

statistics: y = unifpdf (x, a, b)

Continuous uniform probability density function (PDF).

For each element of x, compute the probability density function (PDF) of the continuous uniform distribution with parameters a and b, which define the lower and upper bounds of the interval [a, b]. The size of y is the common size of x, a, and b. A scalar input functions as a constant matrix of the same size as the other inputs.

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

Input arguments must be double or single; integer, logical, and character arrays are rejected. MATLAB accepts a character array and evaluates it at the character codes, which Octave deliberately does not, since a character array is an integer type and integers are refused too.

MATLAB also accepts integer input here, returning the result in the integer class of the input; Octave rejects it, as it does for every other continuous distribution.

See also: unifcdf, unifinv, unifrnd, unifit, unifstat

Source Code: unifpdf

Plot various PDFs from the continuous uniform distribution

 x = 0:0.001:10;
 y1 = unifpdf (x, 2, 5);
 y2 = unifpdf (x, 3, 9);
 plot (x, y1, '-b', x, y2, '-g')
 grid on
 xlim ([0, 10])
 ylim ([0, 0.4])
 legend ({'a = 2, b = 5', 'a = 3, b = 9'}, 'location', 'northeast')
 title ('Continuous uniform PDF')
 xlabel ('values in x')
 ylabel ('density')
plotted figure