Function Reference: tripdf

statistics: y = tripdf (x, a, b, c)

Triangular probability density function (PDF).

For each element of x, compute the probability density function (PDF) of the triangular distribution with lower limit parameter a, peak location (mode) parameter b, and upper limit parameter c. The size of y is the common size of the input arguments. A scalar input functions as a constant matrix of the same size as the other inputs.

Note that the order of the parameter input arguments has been changed after statistics version 1.6.3 in order to be MATLAB compatible with the parameters used in the TriangularDistribution probability distribution object. More specifically, the positions of the parameters b and c have been swapped. As a result, the naming conventions no longer coinside with those used in Wikipedia, in which b denotes the upper limit and c denotes the mode or peak parameter.

Further information about the triangular distribution can be found at https://en.wikipedia.org/wiki/Triangular_distribution

See also: tricdf, triinv, trirnd, tristat

Source Code: tripdf

Example: 1

 

 ## Plot various CDFs from the triangular distribution
 x = 0.001:0.001:10;
 y1 = tripdf (x, 3, 4, 6);
 y2 = tripdf (x, 1, 2, 5);
 y3 = tripdf (x, 2, 3, 9);
 y4 = tripdf (x, 2, 5, 9);
 plot (x, y1, "-b", x, y2, "-g", x, y3, "-r", x, y4, "-c")
 grid on
 xlim ([0, 10])
 legend ({"a = 3, b = 4, c = 6", "a = 1, b = 2, c = 5", ...
          "a = 2, b = 3, c = 9", "a = 2, b = 5, c = 9"}, ...
         "location", "northeast")
 title ("Triangular CDF")
 xlabel ("values in x")
 ylabel ("probability")

                    
plotted figure