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 parameters a, b, and c on the interval [a, b]. 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.

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

See also: tricdf, triinv, trirnd

Source Code: tripdf

Example: 1

 

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

                    
plotted figure