h: Calculate the probability one random beta variable is greater...

Description Usage Arguments Details Source Examples

Description

Find the probability that Beta(a, b) > Beta(c, d), using either an exact solution or a normal approximation. Vectorized across a, b, c and d.

Usage

1
h(a, b, c, d, approx = FALSE, log_h = FALSE)

Arguments

a

alpha parameter for first Beta

b

beta parameter for second Beta

c

alpha parameter for first Beta

d

beta parameter for second Beta

approx

whether to use a normal approximation to the beta

log_h

whether to return log(h(a, b, c, d)) rather than h(a, b, c, d)

Details

The "exact" solution is exact only for integer values of c.

Source

The exact version comes from Evan Miller and Chris Stucchio: https://www.chrisstucchio.com/blog/2014/bayesian_ab_decision_rule.html

John D. Cook lays out the normal approximation here: http://www.johndcook.com/fast_beta_inequality.pdf.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
h(60, 40, 50, 50)
h(60, 40, 50, 50, approx = TRUE)

# compare against random simulation:
mean(rbeta(1e5, 60, 40) > rbeta(1e5, 50, 50))

# it is vectorized across one or multiple arguments
a <- 1:19
h(a, 20 - a, 10, 10)
plot(a, h(a, 20 - a, 10, 10))

dgrtwo/ebbinom documentation built on May 15, 2019, 7:23 a.m.