Last chance! 50% off unlimited learning
Sale ends in
Computes the probability density function (PDF) for the standard Beta
distribution, using a parameterization common in generalized distribution
families. The distribution is parameterized by gamma
(delta
(shape1 = gamma
and shape2 = delta + 1
.
The distribution is defined on the interval (0, 1).
dbeta_(x, gamma, delta, log_prob = FALSE)
A vector of density values (x
, gamma
, delta
).
Returns 0
(or -Inf
if log_prob = TRUE
) for x
outside the interval (0, 1), or NaN
if parameters are invalid
(e.g., gamma <= 0
, delta < 0
).
Vector of quantiles (values between 0 and 1).
First shape parameter (shape1
),
Second shape parameter is delta + 1
(shape2
), requires
shape2 >= 1
. Can be a scalar or a vector.
Default: 0.0 (leading to shape2 = 1
).
Logical; if TRUE
, the logarithm of the density is
returned (FALSE
.
Lopes, J. E.
The probability density function (PDF) calculated by this function corresponds
to a standard Beta distribution beta
).
This specific parameterization arises as a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (dgkw
) obtained
by setting the parameters dmc
) with
Note the difference in the second parameter compared to dbeta
,
where dbeta(x, shape1, shape2)
uses shape2
directly. Here,
shape1 = gamma
and shape2 = delta + 1
.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation,
dbeta
(standard R implementation),
dgkw
(parent distribution density),
dmc
(McDonald/Beta Power density),
pbeta_
, qbeta_
, rbeta_
(other functions for this parameterization, if they exist).
# \donttest{
# Example values
x_vals <- c(0.2, 0.5, 0.8)
gamma_par <- 2.0 # Corresponds to shape1
delta_par <- 3.0 # Corresponds to shape2 - 1
shape1 <- gamma_par
shape2 <- delta_par + 1
# Calculate density using dbeta_
densities <- dbeta_(x_vals, gamma_par, delta_par)
print(densities)
# Compare with stats::dbeta
densities_stats <- stats::dbeta(x_vals, shape1 = shape1, shape2 = shape2)
print(paste("Max difference vs stats::dbeta:", max(abs(densities - densities_stats))))
# Compare with dgkw setting alpha=1, beta=1, lambda=1
densities_gkw <- dgkw(x_vals, alpha = 1.0, beta = 1.0, gamma = gamma_par,
delta = delta_par, lambda = 1.0)
print(paste("Max difference vs dgkw:", max(abs(densities - densities_gkw))))
# Compare with dmc setting lambda=1
densities_mc <- dmc(x_vals, gamma = gamma_par, delta = delta_par, lambda = 1.0)
print(paste("Max difference vs dmc:", max(abs(densities - densities_mc))))
# Calculate log-density
log_densities <- dbeta_(x_vals, gamma_par, delta_par, log_prob = TRUE)
print(log_densities)
print(stats::dbeta(x_vals, shape1 = shape1, shape2 = shape2, log = TRUE))
# Plot the density
curve_x <- seq(0.001, 0.999, length.out = 200)
curve_y <- dbeta_(curve_x, gamma = 2, delta = 3) # Beta(2, 4)
plot(curve_x, curve_y, type = "l", main = "Beta(2, 4) Density via dbeta_",
xlab = "x", ylab = "f(x)", col = "blue")
curve(stats::dbeta(x, 2, 4), add=TRUE, col="red", lty=2)
legend("topright", legend=c("dbeta_(gamma=2, delta=3)", "stats::dbeta(shape1=2, shape2=4)"),
col=c("blue", "red"), lty=c(1,2), bty="n")
# }
Run the code above in your browser using DataLab