Re: Triangular Distribution in Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg74239] Re: [mg74204] Triangular Distribution in Mathematica
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Thu, 15 Mar 2007 05:01:45 -0500 (EST)

```TriangularDistribution/:
PDF[TriangularDistribution[xmin_,xmode_,xmax_],x_]:=
2/(xmax-xmin)*(UnitStep[x-xmin]*(x-xmin)/(xmode-xmin)+
UnitStep[x-xmode]*((
xmax-xmin)*(x-xmode))/((xmax-xmode)*(xmin-xmode))-
UnitStep[x-xmax]*(xmax-x)/(xmax-xmode));

TriangularDistribution/:
CDF[TriangularDistribution[xmin_,xmode_,xmax_],x_]:=
-(((xmax-xmode)*UnitStep[x-xmin]*(x-xmin)^2-(xmin-xmode)*UnitStep[
x-xmax]*(UnitStep[xmax-xmin]*(x-xmax)^2+(x-xmin)*(x-2*xmax+xmin)*
UnitStep[xmin-xmax])-(
xmax-xmin)*UnitStep[x-xmode]*(UnitStep[xmode-xmin]*(x-\
xmode)^2+(x-xmin)*(x+xmin-2*xmode)*UnitStep[xmin-xmode]))/((xmax-
xmin)*(xmax-xmode)*(xmin-xmode)))

xmin=270;
xmax=420;
xmode=392;

Plot[PDF[TriangularDistribution[xmin,xmode,xmax],x],{x,xmin-20,
xmax+20},PlotStyle->Red,PlotRange->All];

Plot[CDF[TriangularDistribution[xmin,xmode,xmax],x],{x,xmin-20,
xmax+20},PlotStyle->Red,PlotRange->All];

You could use Piecewise instead of UnitStep.

Bob Hanlon

> Dear all,
>
> Does any one know how to use triangular distribution in Mathematica?
> Does any one have an add-in? Or a formula that works? I want to get
> the PDF function, plot and the first four moments, mean, variance,
> skew, kurtosis. I have the following parameters for the distribution
> minimum value 270, maximum 415 and  likeliest or mode 392.
>