An R package to work with the triangle distribution and logarithmic triangle distribution

Github Actions Windows Code Coverage CRAN Downloads CRAN
R-CMD-check AppVeyor build status Coverage status CRAN status

See the package documentation here:

Getting Started

Install the R package:

# Stable CRAN version
install.packages(triangle)

# OR development version from GitHub
require(devtools)
devtools::install_github("bertcarnell/triangle")

use the functions:

  • a = minimum
  • b = maximum
  • c = mode

Triangle distribution

# rtriangle(n, a, b, c)
rtriangle(5, 1, 5, 2)

# ptriangle(x, a, b, c)
ptriangle(0:5, 0, 10, 5)

# qtriangle(p, a, b, c)
qtriangle(seq(0, 1, by = 0.2), 1, 10, 3)

# dtriangle(x, a, b, c)
dtriangle(0:4, 0, 10, 5)

Logarithmic triangle distribution

# rltriangle(n, a, b, c, logbase)
rltriangle(5, 1, 100, 10)

# pltriangle(x, a, b, c, logbase)
pltriangle(10^(0:3), 1, 1000, 10)

# qltriangle(p, a, b, c, logbase)
qltriangle(seq(0, 1, by = 0.2), 1, 100, 20)

# dltriangle(x, a, b, c, logbase)
dltriangle(0:5, 1, 10, 5)

Parameter estimates

# triangle method of moments estimates
x <- rtriangle(20, 0, 2, 1.5)
triangle_mom(x)

# triangle maximum likelihood estimates
x <- c(0.1, 0.25, 0.3, 0.4, 0.45, 0.6, 0.75, 0.8)
# triangle_mle(x, debug = FALSE, maxiter = 100)
triangle_mle(x)

# standard triangle (0,1) likelihood estimates
standard_triangle_mle(x)