rekw | R Documentation |
Generates random deviates from the Exponentiated Kumaraswamy (EKw)
distribution with parameters alpha
(\alpha
), beta
(\beta
), and lambda
(\lambda
). This distribution is a
special case of the Generalized Kumaraswamy (GKw) distribution where
\gamma = 1
and \delta = 0
.
rekw(n, alpha, beta, lambda)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
lambda |
Shape parameter |
The generation method uses the inverse transform (quantile) method.
That is, if U
is a random variable following a standard Uniform
distribution on (0, 1), then X = Q(U)
follows the EKw distribution,
where Q(u)
is the EKw quantile function (qekw
):
Q(u) = \left\{ 1 - \left[ 1 - u^{1/\lambda} \right]^{1/\beta} \right\}^{1/\alpha}
This is computationally equivalent to the general GKw generation method
(rgkw
) when specialized for \gamma=1, \delta=0
, as the
required Beta(1, 1) random variate is equivalent to a standard Uniform(0, 1)
variate. The implementation generates U
using runif
and applies the transformation above.
A vector of length n
containing random deviates from the EKw
distribution. The length of the result is determined by n
and the
recycling rule applied to the parameters (alpha
, beta
,
lambda
). Returns NaN
if parameters
are invalid (e.g., alpha <= 0
, beta <= 0
, lambda <= 0
).
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation,
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88.
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
rgkw
(parent distribution random generation),
dekw
, pekw
, qekw
(other EKw functions),
runif
set.seed(2027) # for reproducibility
# Generate 1000 random values from a specific EKw distribution
alpha_par <- 2.0
beta_par <- 3.0
lambda_par <- 1.5
x_sample_ekw <- rekw(1000, alpha = alpha_par, beta = beta_par, lambda = lambda_par)
summary(x_sample_ekw)
# Histogram of generated values compared to theoretical density
hist(x_sample_ekw, breaks = 30, freq = FALSE, # freq=FALSE for density
main = "Histogram of EKw Sample", xlab = "x", ylim = c(0, 3.0))
curve(dekw(x, alpha = alpha_par, beta = beta_par, lambda = lambda_par),
add = TRUE, col = "red", lwd = 2, n = 201)
legend("topright", legend = "Theoretical PDF", col = "red", lwd = 2, bty = "n")
# Comparing empirical and theoretical quantiles (Q-Q plot)
prob_points <- seq(0.01, 0.99, by = 0.01)
theo_quantiles <- qekw(prob_points, alpha = alpha_par, beta = beta_par,
lambda = lambda_par)
emp_quantiles <- quantile(x_sample_ekw, prob_points, type = 7)
plot(theo_quantiles, emp_quantiles, pch = 16, cex = 0.8,
main = "Q-Q Plot for EKw Distribution",
xlab = "Theoretical Quantiles", ylab = "Empirical Quantiles (n=1000)")
abline(a = 0, b = 1, col = "blue", lty = 2)
# Compare summary stats with rgkw(..., gamma=1, delta=0, ...)
# Note: individual values will differ due to randomness
x_sample_gkw <- rgkw(1000, alpha = alpha_par, beta = beta_par, gamma = 1.0,
delta = 0.0, lambda = lambda_par)
print("Summary stats for rekw sample:")
print(summary(x_sample_ekw))
print("Summary stats for rgkw(gamma=1, delta=0) sample:")
print(summary(x_sample_gkw)) # Should be similar
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.