Conjugate prior

From HandWiki
Short description: Concept in probability theory

In Bayesian probability theory, if the posterior distribution p(θx) is in the same probability distribution family as the prior probability distribution p(θ), the prior and posterior are then called conjugate distributions, and the prior is called a conjugate prior for the likelihood function p(xθ).

A conjugate prior is an algebraic convenience, giving a closed-form expression for the posterior; otherwise, numerical integration may be necessary. Further, conjugate priors may give intuition by more transparently showing how a likelihood function updates a prior distribution.

The concept, as well as the term "conjugate prior", were introduced by Howard Raiffa and Robert Schlaifer in their work on Bayesian decision theory.[1] A similar concept had been discovered independently by George Alfred Barnard.[2]

Example

The form of the conjugate prior can generally be determined by inspection of the probability density or probability mass function of a distribution. For example, consider a random variable which consists of the number of successes s in n Bernoulli trials with unknown probability of success q in [0,1]. This random variable will follow the binomial distribution, with a probability mass function of the form

p(s)=(ns)qs(1q)ns

The usual conjugate prior is the beta distribution with parameters (α, β):

p(q)=qα1(1q)β1B(α,β)

where α and β are chosen to reflect any existing belief or information (α=1 and β=1 would give a uniform distribution) and B(α,β) is the Beta function acting as a normalising constant.

In this context, α and β are called hyperparameters (parameters of the prior), to distinguish them from parameters of the underlying model (here q). A typical characteristic of conjugate priors is that the dimensionality of the hyperparameters is one greater than that of the parameters of the original distribution. If all parameters are scalar values, then there will be one more hyperparameter than parameter; but this also applies to vector-valued and matrix-valued parameters. (See the general article on the exponential family, and also consider the Wishart distribution, conjugate prior of the covariance matrix of a multivariate normal distribution, for an example where a large dimensionality is involved.)

If we sample this random variable and get s successes and f=ns failures, then we have

P(s,fq=x)=(s+fs)xs(1x)f,P(q=x)=xα1(1x)β1B(α,β),P(q=xs,f)=P(s,fx)P(x)P(s,fy)P(y)dy=(s+fs)xs+α1(1x)f+β1/B(α,β)y=01((s+fs)ys+α1(1y)f+β1/B(α,β))dy=xs+α1(1x)f+β1B(s+α,f+β),

which is another Beta distribution with parameters (α+s,β+f). This posterior distribution could then be used as the prior for more samples, with the hyperparameters simply adding each extra piece of information as it comes.

Interpretations

Pseudo-observations

It is often useful to think of the hyperparameters of a conjugate prior distribution corresponding to having observed a certain number of pseudo-observations with properties specified by the parameters. For example, the values α and β of a beta distribution can be thought of as corresponding to α1 successes and β1 failures if the posterior mode is used to choose an optimal parameter setting, or α successes and β failures if the posterior mean is used to choose an optimal parameter setting. In general, for nearly all conjugate prior distributions, the hyperparameters can be interpreted in terms of pseudo-observations. This can help provide intuition behind the often messy update equations and help choose reasonable hyperparameters for a prior.

Dynamical system

One can think of conditioning on conjugate priors as defining a kind of (discrete time) dynamical system: from a given set of hyperparameters, incoming data updates these hyperparameters, so one can see the change in hyperparameters as a kind of "time evolution" of the system, corresponding to "learning". Starting at different points yields different flows over time. This is again analogous with the dynamical system defined by a linear operator, but note that since different samples lead to different inferences, this is not simply dependent on time but rather on data over time. For related approaches, see Recursive Bayesian estimation and Data assimilation.

Practical example

Suppose a rental car service operates in your city. Drivers can drop off and pick up cars anywhere inside the city limits. You can find and rent cars using an app.

Suppose you wish to find the probability that you can find a rental car within a short distance of your home address at any time of day.

Over three days you look at the app and find the following number of cars within a short distance of your home address: 𝐱=[3,4,1]

Suppose we assume the data comes from a Poisson distribution. In that case, we can compute the maximum likelihood estimate of the parameters of the model, which is λ=3+4+132.67. Using this maximum likelihood estimate, we can compute the probability that there will be at least one car available on a given day: p(x>0|λ2.67)=1p(x=0|λ2.67)=12.670e2.670!0.93

This is the Poisson distribution that is the most likely to have generated the observed data 𝐱. But the data could also have come from another Poisson distribution, e.g., one with λ=3, or λ=2, etc. In fact, there is an infinite number of Poisson distributions that could have generated the observed data. With relatively few data points, we should be quite uncertain about which exact Poisson distribution generated this data. Intuitively we should instead take a weighted average of the probability of p(x>0|λ) for each of those Poisson distributions, weighted by how likely they each are, given the data we've observed 𝐱.

Generally, this quantity is known as the posterior predictive distribution p(x|𝐱)=θp(x|θ)p(θ|𝐱)dθ, where x is a new data point, 𝐱 is the observed data and θ are the parameters of the model. Using Bayes' theorem we can expand p(θ|𝐱)=p(𝐱|θ)p(θ)p(𝐱), therefore p(x|𝐱)=θp(x|θ)p(𝐱|θ)p(θ)p(𝐱)dθ. Generally, this integral is hard to compute. However, if you choose a conjugate prior distribution p(θ), a closed-form expression can be derived. This is the posterior predictive column in the tables below.

Returning to our example, if we pick the Gamma distribution as our prior distribution over the rate of the Poisson distributions, then the posterior predictive is the negative binomial distribution, as can be seen from the table below. The Gamma distribution is parameterized by two hyperparameters α,β, which we have to choose. By looking at plots of the gamma distribution, we pick α=β=2, which seems to be a reasonable prior for the average number of cars. The choice of prior hyperparameters is inherently subjective and based on prior knowledge.

Given the prior hyperparameters α and β we can compute the posterior hyperparameters α=α+ixi=2+3+4+1=10 and β=β+n=2+3=5

Given the posterior hyperparameters, we can finally compute the posterior predictive of p(x>0|𝐱)=1p(x=0|𝐱)=1NB(0|10,11+5)0.84

This much more conservative estimate reflects the uncertainty in the model parameters, which the posterior predictive takes into account.

Table of conjugate distributions

Let n denote the number of observations. In all cases below, the data is assumed to consist of n points x1,,xn (which will be random vectors in the multivariate cases).

If the likelihood function belongs to the exponential family, then a conjugate prior exists, often also in the exponential family; see Exponential family: Conjugate distributions.

When the likelihood function is a discrete distribution

Likelihood Model parameters Conjugate prior distribution Prior hyperparameters Posterior hyperparameters[note 1] Interpretation of hyperparameters Posterior predictive[note 2]
Bernoulli p (probability) Beta α,β α+i=1nxi,β+ni=1nxi α successes, β failures[note 3] p(x~=1)=αα+β
Binomial
with known number of trials, m
p (probability) Beta α,β α+i=1nxi,β+i=1nNii=1nxi α successes, β failures[note 3] BetaBin(x~|α,β)
(beta-binomial)
Negative binomial
with known failure number, r
p (probability) Beta α,β α+rn,β+i=1nxi α total successes, β failures[note 3] (i.e., βr experiments, assuming r stays fixed) BetaNegBin(x~|α,β)

(beta-negative binomial)

Poisson λ (rate) Gamma k,θ k+i=1nxi, θnθ+1 k total occurrences in 1θ intervals NB(x~k,1θ+1)
(negative binomial)
α,β [note 4] α+i=1nxi, β+n α total occurrences in β intervals NB(x~α,β1+β)
(negative binomial)
Categorical p (probability vector), k (number of categories; i.e., size of p) Dirichlet αk α+(c1,,ck), where ci is the number of observations in category i αi occurrences of category i[note 3] p(x~=i)=αiiαi=αi+ciiαi+n
Multinomial p (probability vector), k (number of categories; i.e., size of p) Dirichlet αk α+i=1n𝐱i αi occurrences of category i[note 3] DirMult(𝐱~α)
(Dirichlet-multinomial)
Hypergeometric
with known total population size, N
M (number of target members) Beta-binomial[3] n=N,α,β α+i=1nxi,β+i=1nNii=1nxi α successes, β failures[note 3]
Geometric p0 (probability) Beta α,β α+n,β+i=1nxi α experiments, β total failures[note 3]

When likelihood function is a continuous distribution

Likelihood Model parameters Conjugate prior distribution Prior hyperparameters Posterior hyperparameters[note 1] Interpretation of hyperparameters Posterior predictive[note 5]
Normal
with known variance σ2
μ (mean) Normal μ0,σ02 11σ02+nσ2(μ0σ02+i=1nxiσ2),(1σ02+nσ2)1 mean was estimated from observations with total precision (sum of all individual precisions) 1/σ02 and with sample mean μ0 𝒩(x~|μ0,σ02+σ2)[4]
Normal
with known precision τ
μ (mean) Normal μ0,τ01 τ0μ0+τi=1nxiτ0+nτ,(τ0+nτ)1 mean was estimated from observations with total precision (sum of all individual precisions)τ0 and with sample mean μ0 𝒩(x~μ0,1τ0+1τ)[4]
Normal
with known mean μ
σ2 (variance) Inverse gamma α,β [note 6] α+n2,β+i=1n(xiμ)22 variance was estimated from 2α observations with sample variance β/α (i.e. with sum of squared deviations 2β, where deviations are from known mean μ) t2α(x~|μ,σ2=β/α)[4]
Normal
with known mean μ
σ2 (variance) Scaled inverse chi-squared ν,σ02 ν+n,νσ02+i=1n(xiμ)2ν+n variance was estimated from ν observations with sample variance σ02 tν(x~|μ,σ02)[4]
Normal
with known mean μ
τ (precision) Gamma α,β [note 4] α+n2,β+i=1n(xiμ)22 precision was estimated from 2α observations with sample variance β/α (i.e. with sum of squared deviations 2β, where deviations are from known mean μ) t2α(x~μ,σ2=β/α)[4]
Normal[note 7] μ and σ2
Assuming exchangeability
Normal-inverse gamma μ0,ν,α,β νμ0+nx¯ν+n,ν+n,α+n2,
β+12i=1n(xix¯)2+nνν+n(x¯μ0)22
  • x¯ is the sample mean
mean was estimated from ν observations with sample mean μ0; variance was estimated from 2α observations with sample mean μ0 and sum of squared deviations 2β t2α(x~μ,β(ν+1)να)[4]
Normal μ and τ
Assuming exchangeability
Normal-gamma μ0,ν,α,β νμ0+nx¯ν+n,ν+n,α+n2,
β+12i=1n(xix¯)2+nνν+n(x¯μ0)22
  • x¯ is the sample mean
mean was estimated from ν observations with sample mean μ0, and precision was estimated from 2α observations with sample mean μ0 and sum of squared deviations 2β t2α(x~μ,β(ν+1)αν)[4]
Multivariate normal with known covariance matrix Σ μ (mean vector) Multivariate normal μ0,Σ0 (Σ01+nΣ1)1(Σ01μ0+nΣ1x¯),
(Σ01+nΣ1)1
  • x¯ is the sample mean
mean was estimated from observations with total precision (sum of all individual precisions)Σ01 and with sample mean μ0 𝒩(𝐱~μ0,Σ0+Σ)[4]
Multivariate normal with known precision matrix Λ μ (mean vector) Multivariate normal μ0,Λ0 (Λ0+nΛ)1(Λ0μ0+nΛx¯),(Λ0+nΛ)
  • x¯ is the sample mean
mean was estimated from observations with total precision (sum of all individual precisions)Λ0 and with sample mean μ0 𝒩(𝐱~μ0,Λ01+Λ1)[4]
Multivariate normal with known mean μ Σ (covariance matrix) Inverse-Wishart ν,Ψ n+ν,Ψ+i=1n(x𝐢μ)(x𝐢μ)T covariance matrix was estimated from ν observations with sum of pairwise deviation products Ψ tνp+1(𝐱~|μ,1νp+1Ψ)[4]
Multivariate normal with known mean μ Λ (precision matrix) Wishart ν,𝐕 n+ν,(𝐕1+i=1n(x𝐢μ)(x𝐢μ)T)1 covariance matrix was estimated from ν observations with sum of pairwise deviation products 𝐕1 tνp+1(𝐱~μ,1νp+1𝐕1)[4]
Multivariate normal μ (mean vector) and Σ (covariance matrix) normal-inverse-Wishart μ0,κ0,ν0,Ψ κ0μ0+nx¯κ0+n,κ0+n,ν0+n,
Ψ+𝐂+κ0nκ0+n(x¯μ0)(x¯μ0)T
  • x¯ is the sample mean
  • 𝐂=i=1n(x𝐢x¯)(x𝐢x¯)T
mean was estimated from κ0 observations with sample mean μ0; covariance matrix was estimated from ν0 observations with sample mean μ0 and with sum of pairwise deviation products Ψ=ν0Σ0 tν0p+1(𝐱~|μ0,κ0+1κ0(ν0p+1)Ψ)[4]
Multivariate normal μ (mean vector) and Λ (precision matrix) normal-Wishart μ0,κ0,ν0,𝐕 κ0μ0+nx¯κ0+n,κ0+n,ν0+n,
(𝐕1+𝐂+κ0nκ0+n(x¯μ0)(x¯μ0)T)1
  • x¯ is the sample mean
  • 𝐂=i=1n(x𝐢x¯)(x𝐢x¯)T
mean was estimated from κ0 observations with sample mean μ0; covariance matrix was estimated from ν0 observations with sample mean μ0 and with sum of pairwise deviation products 𝐕1 tν0p+1(𝐱~μ0,κ0+1κ0(ν0p+1)𝐕1)[4]
Uniform U(0,θ) Pareto xm,k max{x1,,xn,xm},k+n k observations with maximum value xm
Pareto
with known minimum xm
k (shape) Gamma α,β α+n,β+i=1nlnxixm α observations with sum β of the order of magnitude of each observation (i.e. the logarithm of the ratio of each observation to the minimum xm)
Weibull
with known shape β
θ (scale) Inverse gamma[3] a,b a+n,b+i=1nxiβ a observations with sum b of the β'th power of each observation
Log-normal Same as for the normal distribution after applying the natural logarithm to the data for the posterior hyperparameters. Please refer to (Fink 1997) to see the details.
Exponential λ (rate) Gamma α,β [note 4] α+n,β+i=1nxi α observations that sum to β [5] Lomax(x~β,α)
(Lomax distribution)
Gamma
with known shape α
β (rate) Gamma α0,β0 α0+nα,β0+i=1nxi α0/α observations with sum β0 CG(𝐱~α,α0,β0)=β(𝐱~|α,α0,1,β0) [note 8]
Inverse Gamma
with known shape α
β (inverse scale) Gamma α0,β0 α0+nα,β0+i=1n1xi α0/α observations with sum β0
Gamma
with known rate β
α (shape) aα1βαcΓ(α)b a,b,c ai=1nxi,b+n,c+n b or c observations (b for estimating α, c for estimating β) with product a
Gamma[3] α (shape), β (inverse scale) pα1eβqΓ(α)rβαs p,q,r,s pi=1nxi,q+i=1nxi,r+n,s+n α was estimated from r observations with product p; β was estimated from s observations with sum q
Beta α, β Γ(α+β)kpαqβΓ(α)kΓ(β)k p,q,k pi=1nxi,qi=1n(1xi),k+n α and β were estimated from k observations with product p and product of the complements q

See also

Notes

  1. 1.0 1.1 Denoted by the same symbols as the prior hyperparameters with primes added ('). For instance α is denoted α
  2. This is the posterior predictive distribution of a new data point x~ given the observed data points, with the parameters marginalized out. Variables with primes indicate the posterior values of the parameters.
  3. 3.0 3.1 3.2 3.3 3.4 3.5 3.6 The exact interpretation of the parameters of a beta distribution in terms of number of successes and failures depends on what function is used to extract a point estimate from the distribution. The mean of a beta distribution is αα+β, which corresponds to α successes and β failures, while the mode is α1α+β2, which corresponds to α1 successes and β1 failures. Bayesians generally prefer to use the posterior mean rather than the posterior mode as a point estimate, justified by a quadratic loss function, and the use of α and β is more convenient mathematically, while the use of α1 and β1 has the advantage that a uniform Beta(1,1) prior corresponds to 0 successes and 0 failures. The same issues apply to the Dirichlet distribution.
  4. 4.0 4.1 4.2 β is rate or inverse scale. In parameterization of gamma distribution,θ = 1/β and k = α.
  5. This is the posterior predictive distribution of a new data point x~ given the observed data points, with the parameters marginalized out. Variables with primes indicate the posterior values of the parameters. 𝒩 and tn refer to the normal distribution and Student's t-distribution, respectively, or to the multivariate normal distribution and multivariate t-distribution in the multivariate cases.
  6. In terms of the inverse gamma, β is a scale parameter
  7. A different conjugate prior for unknown mean and variance, but with a fixed, linear relationship between them, is found in the normal variance-mean mixture, with the generalized inverse Gaussian as conjugate mixing distribution.
  8. CG() is a compound gamma distribution; β() here is a generalized beta prime distribution.

References

  1. Howard Raiffa and Robert Schlaifer. Applied Statistical Decision Theory. Division of Research, Graduate School of Business Administration, Harvard University, 1961.
  2. Jeff Miller et al. Earliest Known Uses of Some of the Words of Mathematics, "conjugate prior distributions". Electronic document, revision of November 13, 2005, retrieved December 2, 2005.
  3. 3.0 3.1 3.2 Fink, Daniel (1997). "A Compendium of Conjugate Priors". https://courses.physics.ucsd.edu/2018/Fall/physics210b/REFERENCES/conjugate_priors.pdf. 
  4. 4.00 4.01 4.02 4.03 4.04 4.05 4.06 4.07 4.08 4.09 4.10 4.11 4.12 Murphy, Kevin P. (2007), Conjugate Bayesian analysis of the Gaussian distribution, http://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf 
  5. Liu, Han; Wasserman, Larry (2014). Statistical Machine Learning. p. 314. https://www.stat.cmu.edu/~larry/=sml/Bayes.pdf#page=16.