Beta Posterior

Suppose we are being Bayesians, the data model is Binomial(n, p), and the prior for p is Beta(α, β). Then the posterior for p is Beta(x + α, nx + β).

For a specific example, suppose the prior is uniform (α = β = 1) and the observed data were zero successes in 10 trials. Then the posterior distribution for p is Beta(1, 11).

The posterior median is the median of this beta distribution and is computed as follows

The median is the 0.5 quantile, so that is what we use the qbeta function on-line help to compute.

Gamma Posterior

Suppose we are being Bayesians, the data are X1, X2, … Xn and are independent and identically distributed Exponential(λ), and the prior for λ is Gamma(α, β). Then the posterior for λ is Gamma(n + α, &beta + ∑i xi).

For a specific example, suppose the prior is Gamma(3, 3) and the observed data were ∑i xi = 25.4 and n = 5. Then the posterior distribution for λ is Gamma(8, 30.4).

The posterior median is the median of this gamma distribution and is computed as follows

The median is the 0.5 quantile, so that is what we use the qgamma function on-line help to compute.