Description Usage Arguments Value Note Author(s) References Examples
In Balabdaoui et al (2012) the triangular density, defined as
p_x^{a, b, c, d, e} = c(x - a) / (b - a)
for x \in \{a, …, c\} and
p_x^{a, b, c, d, e} = (e - c)(x - b) / (d - b) + c
for x \in \{c, …, d\}, was used to illustrate the limit process of the log-concave MLE. In order to provide the code to generate the limit process figure in Balabdaoui et al (2012, see the example in logConDiscrMLE
for the code to generate that figure) the functions dTriangular
and rTriangular
are included in this package. Note that rTriangular
uses the rejection sampling algorithm in Devroye (1987) which was specifically developed to generate random numbers from a log-concave PMF.
1 2 | dTriangular(a, b, c, d, e)
rTriangular(n, a, b, c, d, e)
|
a |
Left endpoint of triangular pmf. |
b |
Mode of triangular pmf. |
c |
Height at mode. |
d |
Left endpoint. |
e |
Height at left endpoint. |
n |
Number of random numbers to generate. |
dTriangular
returns a vector containing the value of the PMF at all values in x \in \{a, …, d\}.
rTriangular
returns a list containing the elements:
rand |
Vector with generated random numbers of length n. |
x |
Vector (a, …, d). |
dens |
Value of the pmf at x. |
This function is used to generate the plot of the limit process in the help file for the function logConDiscrMLE
.
Kaspar Rufibach (maintainer) kaspar.rufibach@gmail.com
http://www.kasparrufibach.ch
Fadoua Balabdaoui fadoua@ceremade.dauphine.fr
http://www.ceremade.dauphine.fr/~fadoua
Hanna Jankowski hkj@mathstat.yorku.ca
http://www.math.yorku.ca/~hkj
Kathrin Weyermann
Balabdaoui, F., Jankowski, H., Rufibach, K., and Pavlides, M. (2013). Maximum likelihood estimation and confidence bands for a discrete log-concave distribution. J. R. Stat. Soc. Ser. B Stat. Methodol., 75(4), 769–790.
Devroye, L. (1987). A simple generator for discrete log-concave distributions. Computing, 39, 87-91.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## -------------------------------------------------------------
## compute values of triangular density and simulate from it
## -------------------------------------------------------------
a <- 1
b <- 7
c <- 8
d <- 11
e <- 2
n <- 10 ^ 2
## support
x <- seq(a, d, by = 1)
## true density
dens <- dTriangular(a, b, c, d, e)
logdens <- log(dens)
rand <- rTriangular(n, a, b, c, d, e)$rand
## does the same as rTriangular()
rand2 <- sample(x = a:d, size = n, prob = dens, replace = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.