Tips

How to get feedback from the visitors?
Google Docs Form can be used to get feedback from the site visitors. Learn more here.

Some useful handy software

HOW to?

Recent site activity

411days since
Nepalese New Year 2068

Triangular PDF

Triangular Probability Density Function
Version 1.3.0

Triangular pdf is routines for MATLAB to compute and plot triangular probability density function. There are following 4 functions:

tglpdf: Computes and plots triangular probability density function for given value of X (X can be scalar or matrix).
     
tglcdf: Computes and plots triangular cumulative distribution function for given value of X (X can be scalar or matrix).
     
invtglpdf: Computes the value of X from given value of probability density. This is inverse of tglpdf.
       
invtglcdf: Computes the value of X from given value of cumulative distribution. This is inverse of tglcdf.

Probability density function is integrated analytically to compute cumulative distribution function and this gives faster solution than the quad function of
Matlab as used in previous version. Also for invtglcdf, direct solution is obtained, but in previous version it required iterations.
   

Formulae for computing these functions:
L = Support of triangular probability density functions
MU = Location parameter i.e. vertex of triangle
a = MU - L
b = MU + L

TGLPDF
First half of triangle:        pdf1 = (L - MU + X)/L^2   
Second half of triangle:    pdf2 = (L + MU - X)/L^2

TGLCDF
TGLCDF is computed by integrating pdf1 and pdf2 for X. The following analytical
solution for cdf1 and cdf2 is obtained by integration.
First half of triangle:    cdf1 = (0.5*X^2 - a*X + 0.5*a^2)./L^2
Second half of triangle:cdf2 = (-0.5*X^2 + b*X - L*MU - 0.5*MU^2)./L^2

INVTGLPDF
First half of triangle:        X1 = L*(P*L - 1) + MU
Second half of triangle:    X2 = L*(1 - P*L) + MU

INVTGLCDF
First half of triangle:    cdf1 = (0.5*X^2 - a*X + 0.5*a^2)./L^2
Coefficients for solving quadratic equation for X
c1 = 0.5/L^2
c2 = -a/L^2
c3 = 0.5*a^2./L^2 - cdf1
Solving quadratic equation for X gives the following result
X = a + L*sqrt(2cdf1)

Second half of triangle:cdf2 = (-0.5*X^2 + b*X - L*MU - 0.5*MU^2)./L^2
Coefficients for solving quadratic equation for X
d1 = -0.5/L^2
d2 = b/L^2
d3= (-L*MU - 0.5*MU^2)./L^2 + cdf50 - cdf2
Where cdf50 is the cdf at X = MU and equals = 0.5
Solving quadratic equation for X gives the following result
X= b - L*sqrt(2*(1-P));



You can download the file from here.