Description Usage Arguments Details Value Author(s) References See Also Examples
The function computes the probability mass function, the cumulative distribution function, the quantile function of the DSL and implements random generation.
1 2 3 4 |
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 |
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,…
P(X=x; p, q)=\frac{(1-p)(1-q)}{1-pq}q^{|x|}; x=0,-1,-2,-3,…
whereas the cumulative distribution function is given by
F(x; p, q)=P(X≤q x)=\frac{(1-p)q^{-\lfloor x\rfloor}}{1-pq},x<0
F(x; p, q)=P(X≤q x)=1-\frac{(1-q)p^{\lfloor x\rfloor+1}}{1-pq},x≥q 0
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.
Alessandro Barbiero, Riccardo Inchingolo
Tomasz J. Kozubowski, Seidu Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571
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 | # 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)
|
[1] 0.06488901 0.09752381 0.13025316 0.18947368 0.33333333 0.18947368 0.13025316
[8] 0.09752381 0.06488901
[1] 0.1111111 0.4444444 0.9991111
[1] 0 2 6
[1] 0.2941176 0.5482353 0.8149572
[1] 0.1176471 0.4352941 0.7686965
[1] TRUE TRUE TRUE
[1] -2 0 0 1 0 -4 -3 -1 0 0 0 0 0 -1 -1 -2 -4 0 0 -1 -3 0 -1 -3 -1
[26] 0 0 0 5 0 -4 -2 -2 -2 -2 -1 0 -1 1 0 -1 0 -1 -2 1 -2 0 0 -2 0
[51] -3 -3 -2 0 -2 0 0 1 -1 0 -3 0 0 0 -2 -1 0 -2 -1 0 1 -1 -1 -1 0
[76] 1 0 -1 -1 0 0 1 -2 0 -1 -1 0 -3 -1 2 -1 -5 1 0 0 0 0 0 -3 -2
x
-5 -4 -3 -2 -1 0 1 2 5
1 3 8 15 22 41 8 1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.