Generates random deviates from the Kumaraswamy-Kumaraswamy (KKw)
distribution with parameters alpha (\(\alpha\)), beta
(\(\beta\)), delta (\(\delta\)), and lambda (\(\lambda\)).
This distribution is a special case of the Generalized Kumaraswamy (GKw)
distribution where the parameter \(\gamma = 1\).
Arguments
- n
Number of observations. If
length(n) > 1, the length is taken to be the number required. Must be a non-negative integer.- alpha
Shape parameter
alpha> 0. Can be a scalar or a vector. Default: 1.0.- beta
Shape parameter
beta> 0. Can be a scalar or a vector. Default: 1.0.- delta
Shape parameter
delta>= 0. Can be a scalar or a vector. Default: 0.0.- lambda
Shape parameter
lambda> 0. Can be a scalar or a vector. Default: 1.0.
Value
A vector of length n containing random deviates from the KKw
distribution. The length of the result is determined by n and the
recycling rule applied to the parameters (alpha, beta,
delta, lambda). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Details
The generation method uses the inverse transform method based on the quantile
function (qkkw). The KKw quantile function is:
$$
Q(p) = \left[ 1 - \left\{ 1 - \left[ 1 - (1 - p)^{1/(\delta+1)} \right]^{1/\lambda} \right\}^{1/\beta} \right]^{1/\alpha}
$$
Random deviates are generated by evaluating \(Q(p)\) where \(p\) is a
random variable following the standard Uniform distribution on (0, 1)
(runif).
This is equivalent to the general method for the GKw distribution
(rgkw) specialized for \(\gamma=1\). The GKw method generates
\(W \sim \mathrm{Beta}(\gamma, \delta+1)\) and then applies transformations.
When \(\gamma=1\), \(W \sim \mathrm{Beta}(1, \delta+1)\), which can be
generated via \(W = 1 - V^{1/(\delta+1)}\) where \(V \sim \mathrm{Unif}(0,1)\).
Substituting this \(W\) into the GKw transformation yields the same result
as evaluating \(Q(1-V)\) above (noting \(p = 1-V\) is also Uniform).
References
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
Examples
set.seed(123)
x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2)
summary(x)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.01994 0.29325 0.41244 0.42001 0.54531 0.90514
## The sample follows the distribution
hist(x, breaks = 30, freq = FALSE, main = "")
curve(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), add = TRUE)
ks.test(x, pkkw, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2)
#>
#> Asymptotic one-sample Kolmogorov-Smirnov test
#>
#> data: x
#> D = 0.014051, p-value = 0.9891
#> alternative hypothesis: two-sided
#>