Simulating the Truncated Triangular Distribution
2021-02-02
1 Intro
1.1 Motivation
The triangular distribution is a thoroughly studied probability density function (PDF) that usually arises to describe the behavior of a real (\(\mathbb{R}\)) random variable for which little information is available. The distribution is an easy fit for most practical scenarios and, as such, makes it extremely versatile as a means to model non-deterministic scenarios mathematically. To further aid our analysis, we consider the truncated distribution, a generic term that encompasses a transform of any given PDF such that it remains a PDF after restricting the function’s domain to an interval within. Our end goal is to perform a few analytical procedures to find parameterized expressions for a few major descriptive statistics and functions (such as the CDF) of both distributions and implement them in the R language. To show how one may realistically use these implementations we will explore a practical example wherein a triangular distribution and a corresponding truncated triangular distribution are constructed using our implementation and then used to generate random samples with Monte Carlo simulation.
1.2 Your own flare
Those familiar with object-oriented programming might notice our approach takes after a few basic concepts such as constructor functions and composition. If this sounds interesting to you, I encourage you to add your own twist to this exercise and use classes instead of lists but know that it is not a must and we will be using only the most rudimentary features R has to offer.
This implementation was designed with adaptability in mind, meaning that the same approach should also be compatible with other scripting languages such as Python or JavaScript. Plots aside, no external packages or libraries are required, though we use base R’s plot()
family of functions which come pre-installed.
1.3 Project home
All documents, markdown files, scripts, and project images are publicly available in this repository.
All errors are my own. All feedback is welcome.