Statistics

Dickson34
TriangularProbabilityDistribution.pdf

1

PROBABILITY DISTRIBUTIONS R. BEHBOUDI

Triangular Probability Distribution

The triangular probability distribution (also called: “a lack of knowledge distribution”) is a

simplistic continuous model that is mainly used in situations when there is only limited sample

data and information about a population. It is based on the knowledge of a minimum (a lower

value), a maximum (an upper value), and a mode (peak) between those two values. For this

reason, this distribution is very popular in simulation processes related to business decision

models, project management models, financial models, and for modeling noises in digital audio

and video data.

The probability density function (𝒑𝒅𝒇) of the triangular random variable 𝑿 is given by:

𝒇(𝒙) = {

𝟐

(𝒃−𝒂)(𝒄−𝒂) (𝒙 − 𝒂) 𝒊𝒇 𝒙 ≤ 𝒄

𝟐

(𝒃−𝒂)(𝒃−𝒄) (𝒃 − 𝒙) 𝒊𝒇 𝒙 > 𝒄

(1)

The following are some of the important numerical characteristics of the triangular distribution:

2

PROBABILITY DISTRIBUTIONS R. BEHBOUDI

𝒎𝒆𝒂𝒏 = 𝑬(𝒙) = 𝝁 = 𝒂+𝒃+𝒄

𝟑 (2)

𝒎𝒆𝒅𝒊𝒂𝒏 = 𝒎 =

{

𝒂 + √𝟎.𝟓 (𝒃 − 𝒂)(𝒄 − 𝒂) 𝒊𝒇 𝒄 <

𝒂+𝒃

𝟐

𝒄 𝒊𝒇 𝒄 = 𝒂+𝒃

𝟐

𝒃 − √𝟎.𝟓 (𝒃 − 𝒂)(𝒃 − 𝒄) 𝒊𝒇 𝒄 ≥ 𝒂+𝒃

𝟐

(3)

𝒗𝒂𝒓𝒊𝒂𝒏𝒄𝒆 = 𝝈𝟐 = 𝒂𝟐+𝒃𝟐+𝒄𝟐−𝒂𝒃−𝒂𝒄−𝒃𝒄

𝟏𝟖 (4)

The 𝒄𝒅𝒇 (Cumulative density function) 𝑷(𝑿 ≤ 𝒙) of the triangular random variable is:

𝑭(𝒙) =

{

𝟏

(𝒃−𝒂)(𝒄−𝒂) (𝒙 − 𝒂)𝟐 𝒊𝒇 𝒙 < 𝒄

𝒄−𝒂

𝒃−𝒂 𝒊𝒇 𝒙 = 𝒄

𝟏 − 𝟏

(𝒃−𝒂)(𝒃−𝒄) (𝒃 − 𝒙)𝟐 𝒊𝒇 𝒙 > 𝒄

(5)

For example, the following is a display of the cumulative density function of a triangular random variable

with a minimum value of 2, a maximum of 8, and with a peak at 4.

3

PROBABILITY DISTRIBUTIONS R. BEHBOUDI

Random Number Generation of Triangular Random Variables:

The CDF expression given by formula (5) can be used to generate random values according to a specific

triangular distribution. In this method, first a standard uniform random value 𝒓 is created. This value is

then used as a cumulative probability and replaces 𝑭(𝒙) in formula (5). The formula is then solved for the random variable 𝒙. The following rule describes this random number generation:

𝒙 = { 𝒂 + √𝒓 (𝒃 − 𝒂)(𝒄 − 𝒂) 𝒊𝒇 𝒓 ≤

𝒄−𝒂

𝒃−𝒂

𝒃 − √(𝟏 − 𝒓)(𝒃 − 𝒂)(𝒃 − 𝒄) 𝒊𝒇 𝒓 > 𝒄−𝒂

𝒃−𝒂

(6)

Example:

In this example, we will simulate ten million triangular random values in R. We will then compare the

numerical characteristics of this randomly generated set with the expected values.

1. Specify the specification of the triangular distribution:

> a<-2

> b<-8

> c<-4

2. Generate ten-million random values according to the standard uniform distribution:

> N<-10^7

> r2<-runif(N)

3. Implement formula (6) to generate ten million triangular random values (labeled as x2):

> A<-a+sqrt((b-a)*(c-a)*r2)

> B<-b-sqrt((b-a)*(b-c)*(1-r2))

> C<-(c-a)/(b-a)

> x2<-ifelse(r2<C,A,B)

4. Create a relative frequency histogram along with the plot of the density function of the simulated

values:

> hist(x2,freq=F,main="Distribution of the Simulation")

> lines(density(x2),lwd=2,col="red")

4

PROBABILITY DISTRIBUTIONS R. BEHBOUDI

5. We will now compare the observed and the theoretical numerical characteristics of data:

> mean(x2)

[1] 4.666847

> (a+b+c)/3

[1] 4.666667

> median(x2)

[1] 4.536229

> ifelse(c<(a+b)/2,a+sqrt((b-a)*(c-a)/2), b-sqrt((b-a)*(b-c)/2))

[1] 4.44949

> sd(x2)

[1] 1.24714

> sqrt((a^2+b^2+c^2-a*b-a*c-b*c)/18)

[1] 1.247219

6. In fact, we can create a custom function in R that will allow for calculating the triangular cumulative

probabilities:

ptriangular<-function(x,a,b,c) {

KK<-(1/((b-a)*(c-a)))*(x-a)^2

PP<-1-(1/((b-a)*(b-c)))*(b-x)^2

prob<-ifelse(x<c,KK,PP)

return(prob)

}

5

PROBABILITY DISTRIBUTIONS R. BEHBOUDI

For example, suppose that we wish to calculate 𝑷(𝑿 > 𝟓). First observe that:

𝑷(𝑿 > 𝟓) = 𝟏 − 𝑷(𝑿 ≤ 𝟓),

And then use the “ptriangular()” function to calculate the above probability:

> 1-ptriangular(5,2,8,4)

[1] 0.375

7. We can also create a custom function in R that will handle the inverse problems; i.e., problems in

which a cumulative probability (P) is used to calculate the corresponding value (q) of the triangular

random variable:

qtriangular<-function(p,a,b,c) {

QQ<-a+sqrt((b-a)*(c-a)*p)

qq<-b-sqrt((b-a)*(b-c)*(1-p))

q<-ifelse(p<(c-a)/(b-a),QQ,qq)

return(q)

}

For example, the 95th percentile of the triangular distribution of our example can be determined as

follows:

> qtriangular(0.95,2,8,4)

[1] 6.904555

Note that the “qtriangular()” function as defined above can also be used for the random number

generation. The following code will generate 1000 triangular random values according to the triangular

distribution of our example:

> x<-qtriangular(runif(1000),2,8,4)