-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
42 lines (27 loc) · 2.88 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
title: "Simulating the Truncated Triangular Distribution"
author: "Alejandro Mantilla, Data Scientist and Engineer"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
github-repo: MantiMantilla/Truncated-Triangular-Simulation-R
description: "This documentation pertains to the implementation of a Monte Carlo simulation script written in base R."
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Intro
## 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_.
## 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.
## Project home
All documents, markdown files, scripts, and project images are publicly available in [this repository](https://github.com/MantiMantilla/Truncated-Triangular-Simulation-R).
All errors are my own. All feedback is welcome.
## License, Author, and Acknowledgements
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Copyright (c) 2021 [Alejandro Mantilla](https://mantimantilla.github.io/)
Bogotá, Colombia
Special thanks to Alfaima Solano from Universidad de los Andes for their feedback on this project.