Department of Physics and Astronomy

The Forbes Group

Bayesian Analysis

$\newcommand{\vect}[1]{\mathbf{#1}} \newcommand{\uvect}[1]{\hat{#1}} \newcommand{\abs}[1]{\lvert#1\rvert} \newcommand{\norm}[1]{\lVert#1\rVert} \newcommand{\I}{\mathrm{i}} \newcommand{\ket}[1]{\left|#1\right\rangle} \newcommand{\bra}[1]{\left\langle#1\right|} \newcommand{\braket}[1]{\langle#1\rangle} \newcommand{\op}[1]{\mathbf{#1}} \newcommand{\mat}[1]{\mathbf{#1}} \newcommand{\d}{\mathrm{d}} \newcommand{\pdiff}[3][]{\frac{\partial^{#1} #2}{\partial {#3}^{#1}}} \newcommand{\diff}[3][]{\frac{\d^{#1} #2}{\d {#3}^{#1}}} \newcommand{\ddiff}[3][]{\frac{\delta^{#1} #2}{\delta {#3}^{#1}}} \DeclareMathOperator{\erf}{erf} \DeclareMathOperator{\Tr}{Tr} \DeclareMathOperator{\order}{O} \DeclareMathOperator{\diag}{diag} \DeclareMathOperator{\sgn}{sgn} \DeclareMathOperator{\sech}{sech} $

Bayesian Analysis

In this post we perform a simple but explicit analysis of a curve fitting using Bayesian techniques.

In [1]:
import mmf_setup;mmf_setup.nbinit()

This cell contains some definitions for equations and some CSS for styling the notebook. If things look a bit strange, please try the following:

  • Choose "Trust Notebook" from the "File" menu.
  • Re-execute this cell.
  • Reload the notebook.

The Model

Consider the problem of curve fitting:

$$ Y = h(t, a) + X $$

where $X$ is a random variable representing errors with some probability density function (PDF) $f_X(x)$. Within this model, given $t$ and $a$, $Y$ is a random variable with PDF:

$$ f_Y(y) = P(y|t,a) = f_X\bigl(y - h(t, a)\bigr). $$

Maximum Likelihood

Give a set of data $D=(\vect{t}, \vect{y})$, one can precisely formulate the question: what is the probability (likelihood) $P(D|a)$ that this set of data would be obtained from our model given a parameter $a$:

$$ P(D|a) = \prod_{i} f_X\bigl(y_i - h(t_i, a)\bigr). $$

Maximum likelihood techniques choose the best fit for the parameter $a$ to maximize the likelihood:

$$ \sup_{a} P(D|a). $$

Bayes' theorem allows us to compute the a posteriori distribution of the parameter $a$ given the observation of data $D$, updating the prior distribution $P(a)$ normalized by the probability of obtaining the data $D$:

$$ P(a|D) = \frac{P(D|a)P(a)}{P(D)}. $$
In [ ]: