Learn R Programming

DiscreteLaplace (version 1.1.1)

ddlaplace: Probability mass function, cumulative distribution function, quantile function and random generation of the DSL

Description

The function computes the probability mass function, the cumulative distribution function, the quantile function of the DSL and implements random generation.

Usage

ddlaplace(x, p, q) pdlaplace(x, p, q) qdlaplace(prob, p, q) rdlaplace(n, p, q)

Arguments

x
vector of quantiles
p
the first parameter $p$ in $(0,1)$ of the SDL
q
the second parameter $q$ in $(0,1)$ of the SDL
prob
vector of probabilities
n
number of observations

Value

ddlaplace returns the probability of x; pdlaplace returns the cumulate probability of x; qdlaplace returns the prob- quantile; rdlaplace returns a random sample of size n from DSL.

Details

The pmf of the SDL is given by

$P(X=x; p, q)=\frac{(1-p)(1-q)}{1-pq}p^x; x=0,1,2,3,\dots$

$P(X=x; p, q)=\frac{(1-p)(1-q)}{1-pq}q^{|x|}; x=0,-1,-2,-3,\dots$

whereas the cumulative distribution function is given by

$F(x; p, q)=P(X\leq x)=\frac{(1-p)q^{-\lfloor x\rfloor}}{1-pq},x<0$< p="">

$F(x; p, q)=P(X\leq x)=1-\frac{(1-q)p^{\lfloor x\rfloor+1}}{1-pq},x\geq 0$

References

Tomasz J. Kozubowski, Seidu Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571

See Also

ddlaplace2

Examples

Run this code
# pmf
p<-0.7
q<-0.45
x<--10:10
prob<-ddlaplace(x, p, q)
plot(x, prob, type="h")
prob<-ddlaplace(x, q, p) # swap the parameters
plot(x, prob, type="h")
ddlaplace(-4:4, 1:9/10, 9:1/10) # letting p and q be vectors
# cdf
p<-0.2
q<-0.5
x<-c(-3, -1, pi)
pdlaplace(x, p, q)
# quantile function
p<-0.8
q<-0.4
prob<-c(0.2,0.5,0.8)
x<-qdlaplace(prob, p, q)
x # check
upper<-pdlaplace(x, p, q)
upper
lower<-pdlaplace(x-1, p, q)
lower
lower<=prob & prob<=upper
# random generation
n<-100
p<-0.3
q<-0.5
x<-rdlaplace(n, p, q)
x
t<-table(x)
t
plot(t)

Run the code above in your browser using DataLab