Saturday, November 25, 2017

Notes on Bayesian Inference

Notes on Bayesian Inference

Reference

Bayes Theorem

We have,

  • : Parameters
  • : Observations

Bayes rules is as follows:

enter image description here

Probability rules:

  • Sum rules: Marginalization from joint distribution
  • Chain rules:

Point Estimation (Frequentist vs. Bayesian)

Rather than estimate the entire distribution , sometimes it is sufficient to find a single ‘good’ value for . We call this a point estimate.

  • Frequentist thinks parameters are fixed, data are random.
    Maximum Likelihood Estimation:
  • Bayesian thinks parameters are random, data are fixed.
    Maximum Aposteriori Estimation (MAP)
    • MAP estimation is not invariant to non-linear transformations of . E.g. A non-linear transformation , to can shift the posterior mode in such a way that .
    • MAP estimate may not be typical of the posterior.

Bayesian Netwok (Graphical Model)

enter image description here

  • Nodes are random variables
  • Edges indicates dependence (e.g. Grass is wet depends on both sprinkler or rain, and whether sprinkler is on or off depends on rain)
  • Observed variables are shaded nodes; unshaded nodes are hidden
  • Plated denote replicated structure

Joint probability over all the variables in the above model is given by:

enter image description here

Example 1:
enter image description here

Here,

Example 2: Naive Bayes Classifer
enter image description here

Joint Probability

In plate notation, the figure above can be shortened as follows:

enter image description here

Calculation of Posterior Distribution

  • Analytical approach: Use of conjugate prior
  • Converting to optimization problem: variational inference (mean field approximation)
  • Simulations: MCMC methods (metropolis-hastings or gibbs sampling) - see next post.

Since variational inference approximate the posterior, MCMC usually produce higher accuracy - however may be slower to converge, as shown in the figure below:

enter image description here

Conjugate Prior

Point estimation is useful for many applications, however true goal in Bayesian analysis is often to find the full posterior . In most cases, it is difficult to calculate the denominator . One approach to circumventing the integral is to use conjugate priors. Here the idea is, if we choose the ‘right’ prior for a particular likelihood function, then we can compute the posterior without worrying about the integral.

Formally, a prior is conjugate to the likelihood , if the prior and the posterior are from the same family of distribution.

Examples:

  • Beta distribution is conjugate to Bernoulli likelihood. Here is a good example of this for baseball batting average calculation.
  • Dirichlet distribution is conjugate to Multinomial likelihood (e.g. application in LDA)

Variational Inference

  • Very intuitive explanation in this blog
  • Very nice notes on the derivation from CMU here.

If there are no conjugate prior, it might be hard to calculate the posterior. In many cases, we can approximate the posterior with some known distributions.

enter image description here

Steps

We want to find posterior

  • Select a family of distribution parameterized by .
  • Find the best approximation of from by minimizing the KL divergence between the two.

Will there be issue with denominator integral?

Due to the use of KL divergence, we will have:

where . So, we don’t have to worry about .

Evidence Lower Bound (ELBO)

Evidence lower bound is defined as:

Properties: .

Proof:

Minimizing the KL divergence

We can write the KL divergence as:

Therefore,

In words, any that maximizes ELBO, minimizes KL divergence.

Mean Field Approximation

In mean field approximation, the family of distribution is assumed to factorize over the components of , i.e.

and we are trying to achieve


To get to the last line from the previous line, we did the following math:

And,

Co-ordinate Ascent

We can solve this using co-ordinate ascent algorithm, by maximizing a single factor , while keeping all other factors constant.

In summary, we first defined a family of approximations called mean field approximations, in which there are no dependencies between latent variables . Then we decomposed the ELBO into a nice form under mean field assumptions. Then, we derived a coordinate ascent updates to iteratively optimize each local variational approximation under mean field assumptions.

Common Probability Distributions

Gamma Distribution


Here,

  • support of Gamma distribution is

enter image description here

Example: Suppose I ran 5km 100 m every day, i.e. mean 5km with std 100m. We can model this as Gamma distribution. We can also use Gaussian - however, that means we can run negative distance.

enter image description here

Beta Distribution


Here,
- a, b > 0
- support of beta distribution is [0,1], i.e.
-
-

enter image description here

Example: Baseball batting average (its a number between 0 and 1). e.g.