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

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

Source Code: unifpdf

Example: 1

 

 ## 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