Like the semicircle distribution, the triangle distribution is based on a simple geometric shape. The distribution arises naturally when uniformly distributed random variables are transformed in various ways.
The standard triangle distribution with vertex at \(p \in [0, 1]\) (equivalently, shape parameter \(p\)) is a continuous distribution on \( [0, 1] \) with probability density function \(g\) described as follows:
The shape of the probability density function justifies the name triangle distribution.
The graph of \( g \), together with the domain \([0, 1]\), forms a triangle with vertices \((0, 0)\), \((1, 0)\), and \((p, 2)\). The mode of the distribution is \( x = p \).
Using \([0, 1]\) as the base, we can compute the area of the triangle as \(\frac{1}{2} 2 = 1\) so we see immediately that \( g \) is a valid probability density function. The properties are obvious.
Open special distribution simulator and select the triangle distribution. Vary \(p\) (but keep the default values for the other parameters) and note the shape of the probability density function. For selected values of \(p\), run the simulation 1000 times and compare the empirical density function to the probability density function.
The distribution function \( G \) is given as follows:
This result follows from standard calculus since \(G(x) = \int_0^x g(t) \, dt\).
The quantile function \( G^{-1} \) is given by \[ G^{-1}(u) = \begin{cases} \sqrt{u p}, & u \in [0, p] \\ 1 - \sqrt{(1 - u)(1 - p)}, & u \in [p, 1] \end{cases} \]
Open the quantile app and select the triangle distribution. Vary \(p\) (but keep the default values for the other parameters) and note the shape of the distribution function. For selected values of \(p\), compute the first and third quartiles.
Suppose that \( X \) has the standard triangle distribution with vertex \( p \in [0, 1] \). The moments are easy to compute.
Suppose that \( n \in \N \).
This follows from standard calculus, since \(\E(X^n) = \int_0^1 x^n g(x) \, dx\).
From the general moment formula in , we can compute the mean, variance, skewness, and kurtosis.
The mean and variance of \(X\) are
Note that \(\E(X)\) increases from \(\frac{1}{3}\) to \(\frac{2}{3}\) as \(p\) increases from 0 to 1. The graph of \(\var(X)\) is a parabola opening downward; the largest value is \(\frac{1}{18}\) when \(p = 0\) or \(p = 1\) and the smallest value is \(\frac{1}{24}\) when \(p = \frac{1}{2}\).
Open the special distribution simulator and select the triangle distribution. Vary \(p\) (but keep the default values for the other paramters) and note the size and location of the mean \(\pm\) standard deviation bar. For selected values of \(p\), run the simulation 1000 times and compare the empirical mean and standard deviation to the distribution mean and standard deviation.
The skewness of \( X \) is \[ \skw(X) = \frac{\sqrt{2} (1 - 2 p)(1 + p)(2 - p)}{5[1 - p(1 - p)]^{3/2}} \] The kurtosis of \( X \) is \( \kur(X) = \frac{12}{5} \).
Note that \(X\) is positively skewed for \(p \lt \frac{1}{2}\), negatively skewed for \(p \gt \frac{1}{2}\), and symmetric for \(p = \frac{1}{2}\). More specifically, if we indicate the dependence on the parameter \( p \) then \( \skw_{1 - p}(X) = -\skw_p(X) \). Note also that the kurtosis is independent of \(p\), and the excess kurtosis is \( \kur(X) - 3 = -\frac{3}{5} \).
Open the special distribution simulator and select the triangle distribution. Vary \(p\) (but keep the default values for the other paramters) and note the degree of symmetry and the degree to which the distribution is peaked. For selected values of \(p\), run the simulation 1000 times and compare the empirical density function to the probability density function.
If \(X\) has the standard triangle distribution with parameter \(p\), then \(1 - X\) has the standard triangle distribution with parameter \(1 - p\).
The standard triangle distribution has a number of connections with the standard uniform distribution. Recall that a simulation of a random variable with a standard uniform distribution is a random number in computer science.
Suppose that \(U_1\) and \(U_2\) are independent random variables, each with the standard uniform distribution. Then
\(U_1\) and \(U_2\) have CDF \(u \mapsto u\) for \(u \in [0, 1]\)
Suppose again that \(U_1\) and \(U_2\) are independent random variables, each with the standard uniform distribution. Then
In , note that \(Y\) is the sample mean from a random sample of size 2 from the standard uniform distribution. Since the quantile function in has a simple closed-form expression, the standard triangle distribution can be simulated using the random quantile method.
Suppose that \(U\) is has the standard uniform distribution and \(p \in [0, 1]\). Then the random variable below has the standard triangle distribution with parameter \(p\): \[ X = \begin{cases} \sqrt{p U}, & U \le p \\ 1 - \sqrt{(1 -p)(1 - U)}, & p \lt U \le 1 \end{cases} \]
Open the random quantile experiment and select the triangle distribution. Vary \(p\) (but keep the default values for the other parameters) and note the shape of the distribution function/quantile function. For selected values of \(p\), run the experiment 1000 times and watch the random quantiles. Compare the empirical density function, mean, and standard deviation to their distributional counterparts.
The standard triangle distribution can also be simulated using the rejection method, which also works well since the region \(R\) under the probability density function \(g\) is bounded. Recall that this method is based on the following fact: if \((X, Y)\) is uniformly distributed on the rectangular region \(S = \{(x, y): 0 \le x \le 1, 0 \le y \le 2\}\) which contains \(R\), then the conditional distribution of \((X, Y)\) given \((X, Y) \in R\) is uniformly distributed on \(R\), and hence \(X\) has probability density function \(g\).
Open the rejection method experiment and select the triangle distribution. Vary \(p\) (but keep the default values for the other parameters) and note the shape of the probability density function. For selected values of \(p\), run the experiment 1000 times and watch the scatterplot. Compare the empirical density function, mean, and standard deviation to their distributional counterparts.
For the extreme values of the shape parameter, the standard triangle distributions are also beta distributions.
Connections to the beta distribution:
Open the special distribution simulator and select the beta distribution. For parameter values given below, run the simulation 1000 times and compare the empirical density function, mean, and standard deviation to their distributional counterparts.
Like so many standard distributions, the standard triangle distribution is usually generalized by adding location and scale parameters.
Suppose that \(Z\) has the standard triangle distribution with vertex at \(p \in [0, 1]\). For \(a \in \R\) and \(w \in (0, \infty)\), random variable \(X = a + w Z\) has the triangle distribution with location parameter \(a\), and scale parameter \(w\), and shape parameter \(p\)
Suppose that \(X\) has the general triangle distribution given in definition .
\(X\) has probability density function \(f\) given as follows:
Once again, the shape of the probability density function justifies the name triangle distribution.
The graph of \( f \), together with the domain \([a, a + w]\), forms a triangle with vertices \((a, 0)\), \((a + w, 0)\), and \((a + p w, 2/w)\). The mode of the distribution is \( x = a + p w \).
Clearly the general triangle distribution could be parameterized by the left endpoint \(a\), the right endpoint \(b = a + w\) and the location of the vertex \(c = a + p w\), but the location-scale-shape parameterization is better.
Open special distribution simulator and select the triangle distribution. Vary the parameters \( a \), \( w \), and \( p \), and note the shape and location of the probability density function. For selected values of the parameters, run the simulation 1000 times and compare the empirical density function to the probability density function.
The distribution function \( F \) of \( X \) is given as follows:
\( X \) has quantile function \(F^{-1}\) given by \[ F^{-1}(u) = a + \begin{cases} w \sqrt{u p}, & 0 \le u \le p \\ w\left[1 - \sqrt{(1 - u)(1 - p)}\right], & p \le u \le 1 \end{cases} \]
Open the special distribution simulator and select the triangle distribution. Vary the the parameters \( a \), \( w \), and \( p \), and note the shape and location of the distribution function. For selected values of parameters, compute the median and the first and third quartiles.
Suppose again that \(X\) has the triangle distribution with location parameter \(a \in \R\), scale parameter \(w \in (0, \infty)\) and shape parameter \(p \in [0, 1]\). Then we can take \(X = a + w Z\) where \(Z\) has the standard triangle distribution with parameter \(p\). Hence the moments of \(X\) can be computed from the moments of \(Z\) in . Using the binomial theorem and the linearity of expected value we have \[ \E(X^n) = \sum_{k=0}^n \binom{n}{k} w^k a^{n-k} \E(Z^k), \quad n \in \N \] The general results are rather messy.
The mean and variance of \( X \) are
Open the special distribution simulator and select the triangle distribution. Vary the parameters \( a \), \( w \), and \( p \), and note the size and location of the mean \(\pm \) standard deviation bar. For selected values of the paramters, run the simulation 1000 times and compare the empirical mean and standard deviation to the distribution mean and standard deviation.
The skewness of \( X \) is \[ \skw(X) = \frac{\sqrt{2} (1 - 2 p)(1 + p)(2 - p)}{5[1 - p(1 - p)]^{3/2}} \] The kurtosis of \( X \) is \( \kur(X) = \frac{12}{5} \).
These results follow immediately from the skewness and kurtosis of the standard triangle distribution in . Recall that skewness and kurtosis are defined in terms of the standard score, which is independent of the location and scale parameters.
As before, the excess kurtosis is \( \kur(X) - 3 = -\frac{3}{5} \).
Since the triangle distribution is a location-scale family, it's invariant under location-scale transformations. More generally, the family is closed under linear transformations with nonzero slope.
Suppose that \( X \) has the triangle distribution with shape parameter \(a \in \R\), scale parameter \( w \in (0, \infty) \), and shape parameter \( p \in [0, 1] \). If \(b \in \R\) and \( c \in (0, \infty) \) then
As with the standard distribution, there are several connections between the triangle distribution and the continuous uniform distribution.
Suppose that \(V_1\) and \(V_2\) are independent and are uniformly distributed on the interval \([a, a + w]\), where \(a \in \R\) and \(w \in (0, \infty)\). Then
The uniform distribution is itself a location-scale family, so we can write \(V_1 = a + w U_1\) and \(V_2 = a + w U_2\), where \(U_1\) and \(U_2\) are independent and each has the standard uniform distribution. Then \(\min\{V_1, V_2\} = a + w \min\{U_1, U_2\}\) and \(\max\{V_1, V_2\} = a + w \max\{U_1, U_2\}\) so the result follows from the corresponding result for the standard triangle distribution.
Suppose again that \(V_1\) and \(V_2\) are independent and are uniformly distributed on the interval \([a, a + w]\), where \(a \in \R\) and \(w \in (0, \infty)\). Then
As before, we can write \(V_1 = a + w U_1\) and \(V_2 = a + w U_2\), where \(U_1\) and \(U_2\) are independent and each has the standard uniform distribution.
A special case of (b) leads to a connection between the triangle distribution and the Irwin-Hall distribution.
Suppose that \(U_1\) and \(U_2\) are independent random variables, each with the standard uniform distribution. Then \(U_1 + U_2\) has the triangle distribtion with location parameter \(0\), scale parameter \(2\) and shape parameter \(\frac{1}{2}\). But this is also the Irwin-Hall distribution of order \(n = 2\).
Open the special distribution simulator and select the Irwin-Hall distribution. Set \( n = 2 \) and note the shape and location of the probability density function. Run the simulation 1000 times and compare the empirical density function, mean, and standard deviation to their distributional counterparts.
Since we can simulate a variable \(Z\) with the basic triangle distribution with parameter \(p \in [0, 1]\) by the random quantile method in , we can simulate a variable with the triangle distribution that has location parameter \(a \in \R\), scale parameter \(w \in (0, \infty)\), and shape parameter \(p\) by definition in : \(X = a + w Z\). Equivalently, we could compute a random quantile using the quantile function of \(X\) in .
Open the random quantile experiment and select the triangle distribution. Vary the location parameter \(a\), the scale parameter \(w\), and the shape parameter \(p\), and note the shape of the distribution function. For selected values of the parameters, run the experiment 1000 times and watch the random quantiles. Compare the empirical density function, mean and standard deviation to their distributional counterparts.
As with the standard distribution, the general triangle distribution has a bounded probability density function on a bounded interval, and hence can be simulated easily via the rejection method.
Open the rejection method experiment and select the triangle distribution. Vary the parameters and note the shape of the probability density function. For selected values of the parameters, run the experiment 1000 times and watch the scatterplot. Compare the empirical density function, mean, and standard deviation to their distributional counterparts.