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 closedform 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]}
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 in Bernoulli trials with unknown probability of success in [0,1]. This random variable will follow the binomial distribution, with a probability mass function of the form
The usual conjugate prior is the beta distribution with parameters (, ):
where and are chosen to reflect any existing belief or information ( = 1 and = 1 would give a uniform distribution) and Β(, ) 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). It is a typical characteristic of conjugate priors 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 this means that there will be one more hyperparameter than parameter; but this also applies to vectorvalued and matrixvalued parameters. (See the general article on the exponential family, and consider also 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 then sample this random variable and get s successes and f = n  s failures, we have
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.
It is often useful to think of the hyperparameters of a conjugate prior distribution as corresponding to having observed a certain number of pseudoobservations with properties specified by the parameters. For example, the values and of a beta distribution can be thought of as corresponding to successes and 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 pseudoobservations. This can help both in providing an intuition behind the often messy update equations, as well as to help choose reasonable hyperparameters for a prior.
Conjugate priors are analogous to eigenfunctions in operator theory, in that they are distributions on which the "conditioning operator" acts in a wellunderstood way, thinking of the process of changing from the prior to the posterior as an operator.
In both eigenfunctions and conjugate priors, there is a finitedimensional space which is preserved by the operator: the output is of the same form (in the same space) as the input. This greatly simplifies the analysis, as it otherwise considers an infinitedimensional space (space of all functions, space of all distributions).
However, the processes are only analogous, not identical: conditioning is not linear, as the space of distributions is not closed under linear combination, only convex combination, and the posterior is only of the same form as the prior, not a scalar multiple.
Just as one can easily analyze how a linear combination of eigenfunctions evolves under application of an operator (because, with respect to these functions, the operator is diagonalized), one can easily analyze how a convex combination of conjugate priors evolves under conditioning; this is called using a hyperprior, and corresponds to using a mixture density of conjugate priors, rather than a single conjugate prior.
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 inference, this is not simply dependent on time, but rather on data over time. For related approaches, see Recursive Bayesian estimation and Data assimilation.
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:
If we assume the data comes from a Poisson distribution, we can compute the maximum likelihood estimate of the parameters of the model which is Using this maximum likelihood estimate we can compute the probability that there will be at least one car available on a given day:
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 , or , etc. In fact there is an infinite number of poisson distributions that could have generated the observed data and 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 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 where is a new data point, is the observed data and are the parameters of the model. Using Bayes' theorem we can expand therefore Generally, this integral is hard to compute. However, if you choose a conjugate prior distribution , 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 last column in 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 , 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 and
Given the posterior hyperparameters we can finally compute the posterior predictive of
This much more conservative estimate reflect the uncertainty in the model parameters, which the posterior predictive takes into account.
Let n denote the number of observations. In all cases below, the data is assumed to consist of n points (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.
Likelihood  Model parameters  Conjugate prior distribution  Prior hyperparameters  Posterior hyperparameters^{[note 1]}  Interpretation of hyperparameters  Posterior predictive^{[note 2]} 

Bernoulli  p (probability)  Beta  successes, failures^{[note 3]}  
Binomial  p (probability)  Beta  successes, failures^{[note 3]}  (betabinomial)  
Negative binomial with known failure number, r 
p (probability)  Beta  total successes, failures^{[note 3]} (i.e., experiments, assuming stays fixed)  
Poisson  λ (rate)  Gamma  total occurrences in intervals  (negative binomial)  
^{[note 4]}  total occurrences in intervals  (negative binomial)  
Categorical  p (probability vector), k (number of categories; i.e., size of p)  Dirichlet  where is the number of observations in category i  occurrences of category ^{[note 3]}  
Multinomial  p (probability vector), k (number of categories; i.e., size of p)  Dirichlet  occurrences of category ^{[note 3]}  (Dirichletmultinomial)  
Hypergeometric with known total population size, N 
M (number of target members)  Betabinomial^{[3]}  successes, failures^{[note 3]}  
Geometric  p_{0} (probability)  Beta  experiments, total failures^{[note 3]} 
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  mean was estimated from observations with total precision (sum of all individual precisions) and with sample mean  ^{[4]}  
Normal with known precision τ 
μ (mean)  Normal  mean was estimated from observations with total precision (sum of all individual precisions) and with sample mean  ^{[4]}  
Normal with known mean μ 
σ^{2} (variance)  Inverse gamma  ^{[note 6]}  variance was estimated from observations with sample variance (i.e. with sum of squared deviations , where deviations are from known mean )  ^{[4]}  
Normal with known mean μ 
σ^{2} (variance)  Scaled inverse chisquared  variance was estimated from observations with sample variance  ^{[4]}  
Normal with known mean μ 
τ (precision)  Gamma  ^{[note 4]}  precision was estimated from observations with sample variance (i.e. with sum of squared deviations , where deviations are from known mean )  ^{[4]}  
Normal^{[note 7]}  μ and σ^{2} Assuming exchangeability 
Normalinverse gamma 

mean was estimated from observations with sample mean ; variance was estimated from observations with sample mean and sum of squared deviations  ^{[4]}  
Normal  μ and τ Assuming exchangeability 
Normalgamma 

mean was estimated from observations with sample mean , and precision was estimated from observations with sample mean and sum of squared deviations  ^{[4]}  
Multivariate normal with known covariance matrix Σ  μ (mean vector)  Multivariate normal 

mean was estimated from observations with total precision (sum of all individual precisions) and with sample mean  ^{[4]}  
Multivariate normal with known precision matrix Λ  μ (mean vector)  Multivariate normal 

mean was estimated from observations with total precision (sum of all individual precisions) and with sample mean  ^{[4]}  
Multivariate normal with known mean μ  Σ (covariance matrix)  InverseWishart  covariance matrix was estimated from observations with sum of pairwise deviation products  ^{[4]}  
Multivariate normal with known mean μ  Λ (precision matrix)  Wishart  covariance matrix was estimated from observations with sum of pairwise deviation products  ^{[4]}  
Multivariate normal  μ (mean vector) and Σ (covariance matrix)  normalinverseWishart 

mean was estimated from observations with sample mean ; covariance matrix was estimated from observations with sample mean and with sum of pairwise deviation products  ^{[4]}  
Multivariate normal  μ (mean vector) and Λ (precision matrix)  normalWishart 

mean was estimated from observations with sample mean ; covariance matrix was estimated from observations with sample mean and with sum of pairwise deviation products  ^{[4]}  
Uniform  Pareto  observations with maximum value  
Pareto with known minimum x_{m} 
k (shape)  Gamma  observations with sum of the order of magnitude of each observation (i.e. the logarithm of the ratio of each observation to the minimum )  
Weibull with known shape β 
θ (scale)  Inverse gamma^{[3]}  observations with sum of the β'th power of each observation  
Lognormal  Same as for the normal distribution after applying the natural logarithm to the data for the posterior hyperparameters. Please refer to Fink (1997, pp. 21–22) to see the details.  
Exponential  λ (rate)  Gamma  ^{[note 4]}  observations that sum to ^{[5]}  (Lomax distribution)  
Gamma with known shape α 
β (rate)  Gamma  observations with sum  ^{[note 8]}  
Inverse Gamma with known shape α 
β (inverse scale)  Gamma  observations with sum  
Gamma with known rate β 
α (shape)  or observations ( for estimating , for estimating ) with product  
Gamma^{[3]}  α (shape), β (inverse scale)  was estimated from observations with product ; was estimated from observations with sum  
Beta  α, β  and were estimated from observations with product and product of the complements 