-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.qmd
119 lines (76 loc) · 3.22 KB
/
README.qmd
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
format: gfm
engine: julia
execute:
daemon: false
julia:
exeflags: ["--project=@."]
bibliography: "QDistributions.bib"
---
```{julia}
#| label: setup
using QDistributions, Plots
```
# QDistributions.jl
A Julia package for (continuous) quantile distributions and associated functions. Particularly QDistributions implements:
- Quantile function (`quantile`) and complimentary (non-increasing) quantile function (`cquantile`).
- Quantile-based statistics: median (`median`), inter-quartile range (`iqr`), robust (Galton-Bowley) skewness (`rskewness`), robust (Moors') kurtosis (`rkurtosis`).
- Quantile density function (`qdf`), density quantile function (`dqf`) and its logarithm (`logdqf`).
- Inverse of quantile function (`cdf`): close-form, where available, or approximated by a bracketed rootfinder, otherwise. Complimentary CDF (survival function) `ccdf`
- Probability density function (`pdf`), as a thin wrapper over `dqf` and `cdf`; also `logpdf`.
- Sampling from a distribution (`rand` and `sampler` functions)
Where possible, the following functions are also implemented:
- Pearson moments: `mean`, `var`, `skewness`, `kurtosis`
- L-moments: `lmoment`
- L-coefficient of variance (`lvar`), L-skewness ratio (`lskewness`), L-kurtosis ratio (`lkurtosis`).
## Generalized Lambda Distribution (CSW parameterization)
Generalilzed Lambda Distribution reparameterized by @chalabi2012FlexibleDistributionModeling (GLD CSW) is a flexible quantile-based distribution with two shape parameters: asymmetry $\chi$ and steepness $\xi$. Besides, it is an IQR-scaled distribution, meaning that its scale parameter $\sigma$ corresponds to the inter-quartile range (IQR).
```{julia}
#| layout-ncol: 2
d = GLDcsw(1, 5, -0.5, 0.4)
# corner cases
#d = GLDcsw(1, 5, 0, 0.5)
#d = GLDcsw(1, 5, -0.6, (1-0.6)/2)
#d = GLDcsw(1, 5, -0.6, (1+0.6)/2)
#p_grd = ppoints(100)
p_grd = 0:0.01:1
q_grd = quantile(d, p_grd)
f_grd = map(Base.Fix1(qdf,d), p_grd)
dq_grd = map(Base.Fix1(dqf,d), p_grd)
plot(p_grd, q_grd, title="Quantile function", label=string(d))
```
```{julia}
p_grd_aprx = cdf(d, q_grd)
plot(q_grd, p_grd_aprx, title="Inverse quantile function (CDF)", label=string(d))
```
```{julia}
plot(p_grd, f_grd, title="Quantile density function", label=string(d))
```
```{julia}
plot(q_grd, dq_grd, title="Density Quantile Function", label=string(d))
```
## Flattened Skew-Logistic Distribution (FSLD)
One of the most iconic, yet simple quantile-based distributions introduced by @chakrabarty2018QuantileBasedSkewLogistic and @chakrabarty2021GeneralizationQuantileBasedFlattened, combining ideas presented in @gilchrist2000StatisticalModellingQuantile.
```{julia}
#| layout-ncol: 2
using QDistributions, Plots
p_grd = 0:0.01:1
dl = FGLD(1, 5, 0.2, 3)
q_grd = quantile(dl, p_grd)
f_grd = map(Base.Fix1(qdf,dl), p_grd)
dq_grd = map(Base.Fix1(dqf,dl), p_grd)
plot(p_grd, q_grd, title="Quantile function", label=string(dl))
```
```{julia}
p_grd_aprx = cdf(dl, q_grd)
plot(q_grd, p_grd_aprx, title="Inverse quantile function (CDF)", label=string(dl))
```
```{julia}
plot(p_grd, f_grd, title="Quantile density function", label=string(dl))
```
```{julia}
plot(q_grd, dq_grd, title="Density Quantile Function", label=string(dl))
```
## Contributing
## Citing
## References