({{, (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution])[{min,max}] 
represents a symmetric triangular statistical distribution giving values between min and max. }, {, (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution])[]
represents a symmetric triangular statistical distribution giving values between 0 and 1.}, {, (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution])[{min,max},c]
represents a triangular distribution with mode at c.}})

OpenersNotesSection(Spacer1)Details

The mean of a pair of uniformly distributed random variables follows a symmetric triangular distribution. »

(RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]) allows min, max, and c to be any real numbers such that min<c<max.

(RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]) allows min, max, and c to be quantities of the same unit dimensions. »

(RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]) can be used with such functions as (RefLink[Mean, paclet:ref/Mean]), (RefLink[CDF, paclet:ref/CDF]), and (RefLink[RandomVariate, paclet:ref/RandomVariate]). »

OpenersPrimaryExamplesSection(Spacer1)Examples  (23)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Probability density function:

Plot[Table[PDF[TriangularDistribution[{0,4},c],x],{c,{1/2,2,3}}]//Evaluate,{x,0,4},Filling->Axis,Exclusions->None]

Plot[Table[PDF[TriangularDistribution[{0,max},1],x],{max,{2,3,4}}]//Evaluate,{x,0,4},Filling->Axis,Exclusions->None]

PDF[TriangularDistribution[{min,max},c],x]

Cumulative distribution function:

Plot[Table[CDF[TriangularDistribution[{0,4},c],x],{c,{1/2,2,3}}]//Evaluate,{x,0,4},Filling->Axis,Exclusions->None]

Plot[Table[CDF[TriangularDistribution[{0,max},1],x],{max,{2,3,4}}]//Evaluate,{x,0,4},Filling->Axis,Exclusions->None]

CDF[TriangularDistribution[{min,max},c],x]

Mean and variance:

{Mean[TriangularDistribution[{min,max}]],Mean[TriangularDistribution[{min,max},c]]}

{Variance[TriangularDistribution[{min,max}]],Variance[TriangularDistribution[{min,max},c]]}

Median:

Median[TriangularDistribution[{min,max}]]

Median[TriangularDistribution[{min,max},c]]

OpenersExampleSection1(Spacer1)Scope  (8)

Generate a sample of random numbers from a triangular distribution:

data=RandomVariate[TriangularDistribution[{-1,2},1],10^4];

Compare its histogram to the PDF:

Show[
Histogram[data,20,"PDF"],
Plot[PDF[TriangularDistribution[{-1,2},1],x],{x,-1,2},PlotStyle->Thick]]

Distribution parameters estimation:

sample=RandomVariate[TriangularDistribution[{1,4}],10^3];

Estimate the distribution parameters from sample data:

edist=EstimatedDistribution[sample, TriangularDistribution[{min,max}]]

Compare the density histogram of the sample with the PDF of the estimated distribution:

Show[Histogram[sample,Automatic,"PDF"],Plot[PDF[edist,x],{x,1,4},PlotStyle->Thick]]

Skewness varies with the shape parameter c:

Plot[Skewness[TriangularDistribution[{-1,2},c]],{c,-1,2},Filling->Axis]

Skewness[TriangularDistribution[{min,max},c]]

Skewness is 0 in the symmetric case:

Skewness[TriangularDistribution[{min,max}]]

Kurtosis is constant:

Kurtosis[TriangularDistribution[{min,max},c]]

%//N

Different moments with closed forms as functions of parameters:

FormulaGrid[list_,type_]:=Grid[Transpose[{list}],Alignment->{Left,Automatic},Background->{None,{{Lighter[Blend[Switch[type,M,{Blue,Green},CM,{Red,Orange},FM,{Magenta,Cyan},C,{Purple,Red}]],.8],White}}},Dividers->{None,{Darker[Gray,.6],{False},Darker[Gray,.6]}},ItemSize->30]

(RefLink[Moment, paclet:ref/Moment]):

FormulaGrid[Table[Moment[TriangularDistribution[{min,max},c],k]//Factor,{k,3}],M]

(RefLink[Moment, paclet:ref/Moment]) has closed form:

Moment[TriangularDistribution[{min,max},c],r]

(RefLink[CentralMoment, paclet:ref/CentralMoment]):

FormulaGrid[Table[CentralMoment[TriangularDistribution[{min,max},c],k]//Factor,{k,3}],CM]

Closed form for symbolic order:

CentralMoment[TriangularDistribution[{min,max},c],r]

(RefLink[FactorialMoment, paclet:ref/FactorialMoment]):

FormulaGrid[Table[FactorialMoment[TriangularDistribution[{min,max},c],k]//Factor,{k,3}],FM]

(RefLink[Cumulant, paclet:ref/Cumulant]):

FormulaGrid[Table[Cumulant[TriangularDistribution[{min,max},c],k]//Factor,{k,3}],C]

Hazard function:

Plot[Table[HazardFunction[TriangularDistribution[{-3,5},c],x],{c,{-3+0.5,-3+5,-3+7.5}}]//Evaluate,{x,-3,5},Filling->Axis,Exclusions->None]

HazardFunction[TriangularDistribution[{min,max},c],x]

Quantile function:

Plot[Table[Quantile[TriangularDistribution[{0,4},c],q],{c,{1,2,3}}]//Evaluate,{q,0,1},Exclusions->None,Filling->Axis]

Quantile[TriangularDistribution[{min,max},c],q]

Consistent use of (RefLink[Quantity, paclet:ref/Quantity]) in parameters yields (RefLink[QuantityDistribution, paclet:ref/QuantityDistribution]):

density𝒟=TriangularDistribution[{(Quantity[0.98, "g""/""mL", grams per milliliter, (("Grams")/("Milliliters"))]),(Quantity[1.02, "g""/""mL", grams per milliliter, (("Grams")/("Milliliters"))])},(Quantity[1, "g""/""mL", grams per milliliter, (("Grams")/("Milliliters"))])]

Find dispersion of the density:

StandardDeviation[density𝒟]

OpenersExampleSection2(Spacer1)Applications  (2)

An executive is given an account of historical seasonal demands for a product in millions of units. The minimum, maximum, and most likely demands are 1, 1.4, and 1.25, respectively. Find the expected demand and its standard deviation using (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]):

𝓉𝒹=TriangularDistribution[{1,1.4},1.25];

Mean[𝓉𝒹]

StandardDeviation[𝓉𝒹]

The momentum of a secondary particle from a synchrotron beam is modeled by (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]):

p𝒟=TriangularDistribution[{μ-Γ,μ+Γ}];

The distribution is symmetric and attains maximum at p==μ:

maxheight=Simplify[PDF[TriangularDistribution[{μ-Γ,μ+Γ}],μ],Γ>0&&μ∈Reals]

Find momenta where distribution density is at half-height:

p/.Solve[PDF[TriangularDistribution[{μ-Γ,μ+Γ}],p]==maxheight/2&&Γ>0,p,Reals]

Find the full width at half-height:

Last[%]-First[%]//Simplify[#,Γ>0]&

OpenersExampleSection3(Spacer1)Properties & Relations  (6)

Triangular distribution is closed under translation and scaling by a positive factor:

TransformedDistribution[u*k+loc,u\[Distributed]TriangularDistribution[{min,max}]]

TransformedDistribution[u*k+loc,u\[Distributed]TriangularDistribution[{min,max},c]]

Relationships to other distributions:

The mean of two uniform variables follows (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]):

CharacteristicFunction[UniformSumDistribution[2,{min,max}], t/2]

CharacteristicFunction[TriangularDistribution[{min,max}],t]

%-%%//Simplify

Triangular distribution is a special case of (RefLink[BatesDistribution, paclet:ref/BatesDistribution]):

CharacteristicFunction[TriangularDistribution[{0,1}],t]

CharacteristicFunction[BatesDistribution[2],t]

%-%%//Simplify

(RefLink[ArcSinDistribution, paclet:ref/ArcSinDistribution]) is a transformation of (RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]):

TransformedDistribution[Sin[x],x\[Distributed]TriangularDistribution[{-π,π}]]

The default position for c is in the middle of the support interval:

PDF[TriangularDistribution[{min,max},c],x]/.c->(min+max)/2

PDF[TriangularDistribution[{min,max}],x]

%-%%

OpenersExampleSection4(Spacer1)Possible Issues  (2)

(RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]) is not defined when min or max is not real:

Mean[TriangularDistribution[{I,3}]]

(RefLink[TriangularDistribution, paclet:ref/TriangularDistribution]) is not defined when c is not between min and max:

Mean[TriangularDistribution[{1,3},-2]]

Substitution of invalid parameters into symbolic outputs gives results that are not meaningful:

Mean[TriangularDistribution[{min,max}]]/.{min->2,max->1+I}

OpenersExampleSection5(Spacer1)Neat Examples  (1)

PDFs for different c values with CDF contours:

cdf=Function[{x,c},Evaluate[CDF[TriangularDistribution[{0,4},c],x]]];
ql={0.025,0.10,0.25,0.5,0.75,0.90,0.975};
cl=Table[ColorData["Rainbow"][q],{q,Join[{0.0},ql]}];

Legended[Plot3D[PDF[TriangularDistribution[{0,4},c],x],{x,0,4},{c,0.1,3.2},PlotTheme->"Marketing",MeshFunctions->{cdf},Mesh->{ql},MeshStyle->GrayLevel[0.8],MeshShading->cl,AxesLabel->Automatic,PlotPoints->80,BaseStyle->Opacity[0.9],ImageSize->400],BarLegend["Rainbow",ql,LegendLabel->"prob"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[UniformDistribution, paclet:ref/UniformDistribution])  ▪  (RefLink[Piecewise, paclet:ref/Piecewise])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Continuous Distributions, paclet:tutorial/ContinuousDistributions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Bounded Domain Distributions, paclet:guide/BoundedDomainDistributions])}})}})