Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Conjugate prior
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Example == The form of the conjugate prior can generally be determined by inspection of the [[probability density function|probability density]] or [[probability mass function]] of a distribution. For example, consider a [[random variable]] which consists of the number of successes <math>s</math> in <math>n</math> [[Bernoulli trial]]s with ''unknown'' probability of success <math>q</math> in [0,1]. This random variable will follow the [[binomial distribution]], with a probability mass function of the form :<math>p(s) = {n \choose s}q^s (1-q)^{n-s}</math> The usual conjugate prior is the [[beta distribution]] with parameters (<math>\alpha</math>, <math>\beta</math>): :<math>p(q) = {q^{\alpha-1}(1-q)^{\beta-1} \over \Beta(\alpha,\beta)}</math> where <math>\alpha</math> and <math>\beta</math> are chosen to reflect any existing belief or information (<math>\alpha=1</math> and <math>\beta=1</math> would give a [[uniform distribution (continuous)|uniform distribution]]) and <math>\Beta(\alpha,\beta)</math> is the [[Beta function]] acting as a [[normalising constant]]. In this context, <math>\alpha</math> and <math>\beta</math> are called ''[[Hyperparameter (Bayesian statistics)|hyperparameter]]s'' (parameters of the prior), to distinguish them from parameters of the underlying model (here <math>q</math>). 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 <math>s</math> successes and <math>f = n - s</math> failures, then we have :<math>\begin{align} P(s, f \mid q=x) &= {s+f \choose s} x^s(1-x)^f,\\ P(q=x) &= {x^{\alpha-1}(1-x)^{\beta-1} \over \Beta(\alpha,\beta)},\\ P(q=x \mid s,f) &= \frac{P(s, f \mid x)P(x)}{\int P(s, f \mid y)P(y)dy}\\ & = {{{s+f \choose s} x^{s+\alpha-1}(1-x)^{f+\beta-1} / \Beta(\alpha,\beta)} \over \int_{y=0}^1 \left({s+f \choose s} y^{s+\alpha-1}(1-y)^{f+\beta-1} / \Beta(\alpha,\beta)\right) dy} \\ & = {x^{s+\alpha-1}(1-x)^{f+\beta-1} \over \Beta(s+\alpha,f+\beta)}, \end{align}</math> which is another Beta distribution with parameters <math>(\alpha + s, \beta + f)</math>. 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 <math>\alpha</math> and <math>\beta</math> of a [[beta distribution]] can be thought of as corresponding to <math>\alpha-1</math> successes and <math>\beta-1</math> failures if the posterior mode is used to choose an optimal parameter setting, or <math>\alpha</math> successes and <math>\beta</math> 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: <math>\mathbf{x} = [3,4,1]</math> Suppose we assume the data comes from a [[Poisson distribution]]. In that case, we can compute the [[Maximum likelihood estimation|maximum likelihood]] estimate of the parameters of the model, which is <math display="inline">\lambda = \frac{3+4+1}{3} \approx 2.67.</math> Using this maximum likelihood estimate, we can compute the probability that there will be at least one car available on a given day: <math display="inline">p(x>0 | \lambda \approx 2.67) = 1 - p(x=0 | \lambda \approx 2.67) = 1-\frac{2.67^0 e^{-2.67}}{0!} \approx 0.93</math> This is the Poisson distribution that is ''the'' most likely to have generated the observed data <math>\mathbf{x}</math>. But the data could also have come from another Poisson distribution, e.g., one with <math>\lambda = 3</math>, or <math>\lambda = 2</math>, 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 <math>p(x>0| \lambda)</math> for each of those Poisson distributions, weighted by how likely they each are, given the data we've observed <math>\mathbf{x}</math>. Generally, this quantity is known as the [[posterior predictive distribution]] <math>p(x|\mathbf{x}) = \int_\theta p(x|\theta)p(\theta|\mathbf{x})d\theta\,,</math> where <math>x</math> is a new data point, <math>\mathbf{x}</math> is the observed data and <math>\theta</math> are the parameters of the model. Using [[Bayes' theorem]] we can expand <math>p(\theta|\mathbf{x}) = \frac{p(\mathbf{x}|\theta)p(\theta)}{p(\mathbf{x})}\,,</math> therefore <math>p(x|\mathbf{x}) = \int_\theta p(x|\theta)\frac{p(\mathbf{x}|\theta)p(\theta)}{p(\mathbf{x})}d\theta\,.</math> Generally, this integral is hard to compute. However, if you choose a conjugate prior distribution <math>p(\theta)</math>, 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 <math>\alpha, \beta</math>, which we have to choose. By looking at plots of the gamma distribution, we pick <math>\alpha = \beta = 2</math>, 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 <math>\alpha</math> and <math>\beta</math> we can compute the posterior hyperparameters <math display="inline">\alpha' = \alpha + \sum_i x_i = 2 + 3+4+1 = 10</math> and <math display="inline">\beta' = \beta + n = 2+3 = 5</math> Given the posterior hyperparameters, we can finally compute the posterior predictive of <math display="inline">p(x>0|\mathbf{x}) = 1-p(x=0|\mathbf{x}) = 1 - NB\left(0\, |\, 10, \frac{5}{1+5}\right) \approx 0.84</math> This much more conservative estimate reflects the uncertainty in the model parameters, which the posterior predictive takes into account.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)