The function computes the probability mass function, the cumulative distribution function, the quantile function of the ADSL and provides random generation of samples from the same model
The probability mass funtion of the ADSL distribution is given by:
P(X=x;p,q)=frac{log p}{log (pq)}q^{-(x+1)}(1-q) for x=…, -2, -1
and
P(X=x;p,q)=frac{log q}{log (pq)}p^{x}(1-p) for x=0, 1, 2, …
Its cumulative distribution function is:
F(x;p,q)=frac{log p}{log (pq)}q^{-(lfloor x
floor+1)} for x<0
and
F(x;p,q)=1-frac{log q}{log (pq)}p^{(lfloor x
floor+1)} for x≥q 0
Value
ddlaplace2 returns the probability of x; pdlaplace2 returns the cumulate probability of x; qdlaplace2 returns the prob- quantile; rdlaplace2 returns a random sample of size n from ADSL.
Author(s)
Alessandro Barbiero, Riccardo Inchingolo
References
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
See Also
ddlaplace
Examples
# pmf
p <- 0.7
q <- 0.45
x <- -10:10
prob <- ddlaplace2(x, p, q)
plot(x, prob, type="h")
# swap the parameters
prob <- ddlaplace2(x, q, p)
plot(x, prob, type="h")
# letting p and q be vectors...
ddlaplace2(-4:4, 1:9/10, 9:1/10)
# cdf
pdlaplace2(x, p, q)
pdlaplace2(pi, p, q)
pdlaplace2(floor(pi), p, q)
# quantile function
qdlaplace(1:9/10, p, q)
# random generation
y <- rdlaplace2(n=1000, p, q)
plot(table(y))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(DiscreteLaplace)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DiscreteLaplace/ddlaplace2.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ddlaplace2
> ### Title: Probability mass function of the ADSL
> ### Aliases: ddlaplace2 pdlaplace2 qdlaplace2 rdlaplace2 palaplace2
> ### Keywords: distribution
>
> ### ** Examples
>
> # pmf
> p <- 0.7
> q <- 0.45
> x <- -10:10
> prob <- ddlaplace2(x, p, q)
> plot(x, prob, type="h")
> # swap the parameters
> prob <- ddlaplace2(x, q, p)
> plot(x, prob, type="h")
> # letting p and q be vectors...
> ddlaplace2(-4:4, 1:9/10, 9:1/10)
[1] 0.06971023 0.11241413 0.16200599 0.25682299 0.25000000 0.15409380 0.11340420
[8] 0.08993130 0.06273921
> # cdf
> pdlaplace2(x, p, q)
[1] 0.0002336332 0.0005191849 0.0011537442 0.0025638761 0.0056975024
[6] 0.0126611164 0.0281358143 0.0625240318 0.1389422929 0.3087606509
[11] 0.5161324557 0.6612927190 0.7629049033 0.8340334323 0.8838234026
[16] 0.9186763818 0.9430734673 0.9601514271 0.9721059990 0.9804741993
[21] 0.9863319395
> pdlaplace2(pi, p, q)
[1] 0.842207
> pdlaplace2(floor(pi), p, q)
[1] 0.8340334
> # quantile function
> qdlaplace(1:9/10, p, q)
[1] -1 0 0 0 1 1 2 3 5
> # random generation
> y <- rdlaplace2(n=1000, p, q)
> plot(table(y))
>
>
>
>
>
> dev.off()
null device
1
>