Skip to contents

This function calculates the cumulative distribution function (CDF) of the difference between two independent beta-distributed random variables using Appell's first hypergeometric function. Specifically, it computes P(X1 - X2 > q) where X1 ~ Beta(alpha1, beta1) and X2 ~ Beta(alpha2, beta2).

Usage

pBetadiff(q, alpha1, alpha2, beta1, beta2)

Arguments

q

A numeric value representing the quantile threshold.

alpha1

A positive numeric value representing the first shape parameter of the first beta distribution.

alpha2

A positive numeric value representing the first shape parameter of the second beta distribution.

beta1

A positive numeric value representing the second shape parameter of the first beta distribution.

beta2

A positive numeric value representing the second shape parameter of the second beta distribution.

Value

A numeric value representing P(X1 - X2 > q), the probability that the difference between the two beta variables exceeds the quantile q.

Details

The function uses a piecewise approach based on the range of the difference π = X1 - X2:

  • For π ∈ [-1, 0): Uses Appell's F1 function with specific parameters

  • For π ∈ [0, 1): Uses a different parameterization of Appell's F1 function

  • Special case handling when π = 0 and certain parameter conditions are met

Examples

# Calculate P(Beta(0.5, 0.5) - Beta(0.5, 0.5) > 0.2)
pBetadiff(0.2, 0.5, 0.5, 0.5, 0.5)
#> [1] 0.3377407

# Calculate P(Beta(2, 3) - Beta(1, 4) > -0.1)
pBetadiff(-0.1, 2, 3, 1, 4)
#> [1] 0.8614457

# Calculate P(Beta(1, 1) - Beta(1, 1) > 0)
pBetadiff(0, 1, 1, 1, 1)
#> [1] 0.5