Last chance! 50% off unlimited learning
Sale ends in
Generates random deviates from the Beta-Kumaraswamy (BKw) distribution
with parameters alpha
(beta
(gamma
(delta
(
rbkw(n, alpha, beta, gamma, delta)
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
).
Number of observations. If length(n) > 1
, the length is
taken to be the number required. Must be a non-negative integer.
Shape parameter alpha
> 0. Can be a scalar or a vector.
Default: 1.0.
Shape parameter beta
> 0. Can be a scalar or a vector.
Default: 1.0.
Shape parameter gamma
> 0. Can be a scalar or a vector.
Default: 1.0.
Shape parameter delta
>= 0. Can be a scalar or a vector.
Default: 0.0.
Lopes, J. E.
The generation method uses the relationship between the GKw distribution and the
Beta distribution. The general procedure for GKw (rgkw
) is:
If
For the BKw distribution,
Generate rbeta
.
Compute the BKw variate
This procedure is implemented efficiently, handling parameter recycling as needed.
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
# \donttest{
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
# }
Run the code above in your browser using DataLab