Table of Contents
The Triangular Distribution is a probability distribution used to model data that is bounded within a certain range, with higher likelihood of occurrences towards the middle of the range. In R, this distribution can be implemented using the “rtriangle” function from the “triangle” package. This function allows for the generation of random numbers following a triangular distribution, which can be useful in various statistical analyses and simulations. Some examples of its application include modeling of income data, project duration estimation, and risk assessment in finance. Additionally, the triangular distribution can also be used to fit data and make predictions about future outcomes. Overall, the Triangular Distribution in R provides a versatile tool for analyzing and understanding data with bounded values.
Use the Triangular Distribution in R (With Examples)
The is a continuous probability distribution with a probability density function shaped like a triangle.
It is defined by three values:
- The minimum value a
- The maximum value b
- The peak value c

To calculate probabilities for the triangular distribution in R we can use the ptri() function from the EnvStats package, which uses the following syntax:
ptri(q, min = 0, max = 1, mode = 1/2)
where:
- q: Quantile of interest
- min: The minimum value of the distribution
- max: The maximum value of the distribution
- mode: The peak value of the distribution
The following examples show how to use this function in practice in R.
Example 1: Calculating Probability Less Than Some Value
Suppose a restaurant estimates that their total sales for the upcoming week will be a minimum of $10,000, a maximum of $30,000, and most likely $25,000.

What is the probability that the restaurant makes less than $20,000 total sales?
We can use the following code to calculate this probability:
library(EnvStats) #calculate probability ptri(q = 20000, min = 10000, max = 30000, mode = 25000) [1] 0.3333333
The probability that the restaurant makes less than $20,000 total sales is .333.
Example 2: Calculating Probability Greater Than Some Value

What is the probability that more than 1,500 customers enter the shop in a given week?
We can use the following code to calculate this probability:
library(EnvStats) #calculate probability 1 - ptri(q = 1500, min = 500, max = 2000, mode = 1200) [1] 0.2083333
The probability that more than 1,500 customers enter the shop is about .208.
Note: You can find the complete documentation for the ptri() function .
Additional Resources
The following tutorials explain how to work with other probability distributions in R:
Cite this article
stats writer (2024). How can the Triangular Distribution be used in R, and what are some examples of its application?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-the-triangular-distribution-be-used-in-r-and-what-are-some-examples-of-its-application/
stats writer. "How can the Triangular Distribution be used in R, and what are some examples of its application?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-can-the-triangular-distribution-be-used-in-r-and-what-are-some-examples-of-its-application/.
stats writer. "How can the Triangular Distribution be used in R, and what are some examples of its application?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-the-triangular-distribution-be-used-in-r-and-what-are-some-examples-of-its-application/.
stats writer (2024) 'How can the Triangular Distribution be used in R, and what are some examples of its application?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-the-triangular-distribution-be-used-in-r-and-what-are-some-examples-of-its-application/.
[1] stats writer, "How can the Triangular Distribution be used in R, and what are some examples of its application?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How can the Triangular Distribution be used in R, and what are some examples of its application?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
