rbkw | R Documentation |
Generates random deviates from the Beta-Kumaraswamy (BKw) distribution
with parameters alpha
(\alpha
), beta
(\beta
),
gamma
(\gamma
), and delta
(\delta
). This distribution
is a special case of the Generalized Kumaraswamy (GKw) distribution where
the parameter \lambda = 1
.
rbkw(n, alpha, beta, gamma, delta)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
The generation method uses the relationship between the GKw distribution and the
Beta distribution. The general procedure for GKw (rgkw
) is:
If W \sim \mathrm{Beta}(\gamma, \delta+1)
, then
X = \{1 - [1 - W^{1/\lambda}]^{1/\beta}\}^{1/\alpha}
follows the
GKw(\alpha, \beta, \gamma, \delta, \lambda
) distribution.
For the BKw distribution, \lambda=1
. Therefore, the algorithm simplifies to:
Generate V \sim \mathrm{Beta}(\gamma, \delta+1)
using
rbeta
.
Compute the BKw variate X = \{1 - (1 - V)^{1/\beta}\}^{1/\alpha}
.
This procedure is implemented efficiently, handling parameter recycling as needed.
A vector of length n
containing random deviates from the BKw
distribution. The length of the result is determined by n
and the
recycling rule applied to the parameters (alpha
, beta
,
gamma
, delta
). Returns NaN
if parameters
are invalid (e.g., alpha <= 0
, beta <= 0
, gamma <= 0
,
delta < 0
).
Lopes, J. E.
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),
dbkw
, pbkw
, qbkw
(other BKw functions),
rbeta
set.seed(2026) # for reproducibility
# Generate 1000 random values from a specific BKw distribution
alpha_par <- 2.0
beta_par <- 1.5
gamma_par <- 1.0
delta_par <- 0.5
x_sample_bkw <- rbkw(1000, alpha = alpha_par, beta = beta_par,
gamma = gamma_par, delta = delta_par)
summary(x_sample_bkw)
# Histogram of generated values compared to theoretical density
hist(x_sample_bkw, breaks = 30, freq = FALSE, # freq=FALSE for density
main = "Histogram of BKw Sample", xlab = "x", ylim = c(0, 2.5))
curve(dbkw(x, alpha = alpha_par, beta = beta_par, gamma = gamma_par,
delta = delta_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 <- qbkw(prob_points, alpha = alpha_par, beta = beta_par,
gamma = gamma_par, delta = delta_par)
emp_quantiles <- quantile(x_sample_bkw, prob_points, type = 7)
plot(theo_quantiles, emp_quantiles, pch = 16, cex = 0.8,
main = "Q-Q Plot for BKw Distribution",
xlab = "Theoretical Quantiles", ylab = "Empirical Quantiles (n=1000)")
abline(a = 0, b = 1, col = "blue", lty = 2)
# Compare summary stats with rgkw(..., lambda=1, ...)
# Note: individual values will differ due to randomness
x_sample_gkw <- rgkw(1000, alpha = alpha_par, beta = beta_par, gamma = gamma_par,
delta = delta_par, lambda = 1.0)
print("Summary stats for rbkw sample:")
print(summary(x_sample_bkw))
print("Summary stats for rgkw(lambda=1) 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.