last updated: October 24, 2024

Bayesian Statistics

\(\newcommand{\footnotename}{footnote}\) \(\def \LWRfootnote {1}\) \(\newcommand {\footnote }[2][\LWRfootnote ]{{}^{\mathrm {#1}}}\) \(\newcommand {\footnotemark }[1][\LWRfootnote ]{{}^{\mathrm {#1}}}\) \(\let \LWRorighspace \hspace \) \(\renewcommand {\hspace }{\ifstar \LWRorighspace \LWRorighspace }\) \(\newcommand {\mathnormal }[1]{{#1}}\) \(\newcommand \ensuremath [1]{#1}\) \(\newcommand {\LWRframebox }[2][]{\fbox {#2}} \newcommand {\framebox }[1][]{\LWRframebox } \) \(\newcommand {\setlength }[2]{}\) \(\newcommand {\addtolength }[2]{}\) \(\newcommand {\setcounter }[2]{}\) \(\newcommand {\addtocounter }[2]{}\) \(\newcommand {\arabic }[1]{}\) \(\newcommand {\number }[1]{}\) \(\newcommand {\noalign }[1]{\text {#1}\notag \\}\) \(\newcommand {\cline }[1]{}\) \(\newcommand {\directlua }[1]{\text {(directlua)}}\) \(\newcommand {\luatexdirectlua }[1]{\text {(directlua)}}\) \(\newcommand {\protect }{}\) \(\def \LWRabsorbnumber #1 {}\) \(\def \LWRabsorbquotenumber "#1 {}\) \(\newcommand {\LWRabsorboption }[1][]{}\) \(\newcommand {\LWRabsorbtwooptions }[1][]{\LWRabsorboption }\) \(\def \mathchar {\ifnextchar "\LWRabsorbquotenumber \LWRabsorbnumber }\) \(\def \mathcode #1={\mathchar }\) \(\let \delcode \mathcode \) \(\let \delimiter \mathchar \) \(\def \oe {\unicode {x0153}}\) \(\def \OE {\unicode {x0152}}\) \(\def \ae {\unicode {x00E6}}\) \(\def \AE {\unicode {x00C6}}\) \(\def \aa {\unicode {x00E5}}\) \(\def \AA {\unicode {x00C5}}\) \(\def \o {\unicode {x00F8}}\) \(\def \O {\unicode {x00D8}}\) \(\def \l {\unicode {x0142}}\) \(\def \L {\unicode {x0141}}\) \(\def \ss {\unicode {x00DF}}\) \(\def \SS {\unicode {x1E9E}}\) \(\def \dag {\unicode {x2020}}\) \(\def \ddag {\unicode {x2021}}\) \(\def \P {\unicode {x00B6}}\) \(\def \copyright {\unicode {x00A9}}\) \(\def \pounds {\unicode {x00A3}}\) \(\let \LWRref \ref \) \(\renewcommand {\ref }{\ifstar \LWRref \LWRref }\) \( \newcommand {\multicolumn }[3]{#3}\) \(\require {textcomp}\) \(\newcommand {\intertext }[1]{\text {#1}\notag \\}\) \(\let \Hat \hat \) \(\let \Check \check \) \(\let \Tilde \tilde \) \(\let \Acute \acute \) \(\let \Grave \grave \) \(\let \Dot \dot \) \(\let \Ddot \ddot \) \(\let \Breve \breve \) \(\let \Bar \bar \) \(\let \Vec \vec \) \(\require {colortbl}\) \(\let \LWRorigcolumncolor \columncolor \) \(\renewcommand {\columncolor }[2][named]{\LWRorigcolumncolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let \LWRorigrowcolor \rowcolor \) \(\renewcommand {\rowcolor }[2][named]{\LWRorigrowcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let \LWRorigcellcolor \cellcolor \) \(\renewcommand {\cellcolor }[2][named]{\LWRorigcellcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\require {mathtools}\) \(\newenvironment {crampedsubarray}[1]{}{}\) \(\newcommand {\smashoperator }[2][]{#2\limits }\) \(\newcommand {\SwapAboveDisplaySkip }{}\) \(\newcommand {\LaTeXunderbrace }[1]{\underbrace {#1}}\) \(\newcommand {\LaTeXoverbrace }[1]{\overbrace {#1}}\) \(\newcommand {\LWRmultlined }[1][]{\begin {multline*}}\) \(\newenvironment {multlined}[1][]{\LWRmultlined }{\end {multline*}}\) \(\let \LWRorigshoveleft \shoveleft \) \(\renewcommand {\shoveleft }[1][]{\LWRorigshoveleft }\) \(\let \LWRorigshoveright \shoveright \) \(\renewcommand {\shoveright }[1][]{\LWRorigshoveright }\) \(\newcommand {\shortintertext }[1]{\text {#1}\notag \\}\) \(\newcommand {\vcentcolon }{\mathrel {\unicode {x2236}}}\) \(\renewcommand {\intertext }[2][]{\text {#2}\notag \\}\) \(\newenvironment {fleqn}[1][]{}{}\) \(\newenvironment {ceqn}{}{}\) \(\newenvironment {darray}[2][c]{\begin {array}[#1]{#2}}{\end {array}}\) \(\newcommand {\dmulticolumn }[3]{#3}\) \(\newcommand {\LWRnrnostar }[1][0.5ex]{\\[#1]}\) \(\newcommand {\nr }{\ifstar \LWRnrnostar \LWRnrnostar }\) \(\newcommand {\mrel }[1]{\begin {aligned}#1\end {aligned}}\) \(\newcommand {\underrel }[2]{\underset {#2}{#1}}\) \(\newcommand {\medmath }[1]{#1}\) \(\newcommand {\medop }[1]{#1}\) \(\newcommand {\medint }[1]{#1}\) \(\newcommand {\medintcorr }[1]{#1}\) \(\newcommand {\mfrac }[2]{\frac {#1}{#2}}\) \(\newcommand {\mbinom }[2]{\binom {#1}{#2}}\) \(\newenvironment {mmatrix}{\begin {matrix}}{\end {matrix}}\) \(\newcommand {\displaybreak }[1][]{}\) \( \def \offsyl {(\oslash )} \def \msconly {(\Delta )} \) \( \DeclareMathOperator {\var }{var} \DeclareMathOperator {\cov }{cov} \DeclareMathOperator {\Bin }{Bin} \DeclareMathOperator {\Geo }{Geometric} \DeclareMathOperator {\Beta }{Beta} \DeclareMathOperator {\Unif }{Uniform} \DeclareMathOperator {\Gam }{Gamma} \DeclareMathOperator {\Normal }{N} \DeclareMathOperator {\Exp }{Exp} \DeclareMathOperator {\Cauchy }{Cauchy} \DeclareMathOperator {\Bern }{Bernoulli} \DeclareMathOperator {\Poisson }{Poisson} \DeclareMathOperator {\Weibull }{Weibull} \DeclareMathOperator {\IGam }{IGamma} \DeclareMathOperator {\NGam }{NGamma} \DeclareMathOperator {\ChiSquared }{ChiSquared} \DeclareMathOperator {\Pareto }{Pareto} \DeclareMathOperator {\NBin }{NegBin} \DeclareMathOperator {\Studentt }{Student-t} \DeclareMathOperator *{\argmax }{arg\,max} \DeclareMathOperator *{\argmin }{arg\,min} \) \( \def \to {\rightarrow } \def \iff {\Leftrightarrow } \def \ra {\Rightarrow } \def \sw {\subseteq } \def \mc {\mathcal } \def \mb {\mathbb } \def \sc {\setminus } \def \wt {\widetilde } \def \v {\textbf } \def \E {\mb {E}} \def \P {\mb {P}} \def \R {\mb {R}} \def \C {\mb {C}} \def \N {\mb {N}} \def \Q {\mb {Q}} \def \Z {\mb {Z}} \def \B {\mb {B}} \def \~{\sim } \def \-{\,;\,} \def \qed {$\blacksquare $} \CustomizeMathJax {\def \1{\unicode {x1D7D9}}} \def \cadlag {c\`{a}dl\`{a}g} \def \p {\partial } \def \l {\left } \def \r {\right } \def \Om {\Omega } \def \om {\omega } \def \eps {\epsilon } \def \de {\delta } \def \ov {\overline } \def \sr {\stackrel } \def \Lp {\mc {L}^p} \def \Lq {\mc {L}^p} \def \Lone {\mc {L}^1} \def \Ltwo {\mc {L}^2} \def \toae {\sr {\rm a.e.}{\to }} \def \toas {\sr {\rm a.s.}{\to }} \def \top {\sr {\mb {\P }}{\to }} \def \tod {\sr {\rm d}{\to }} \def \toLp {\sr {\Lp }{\to }} \def \toLq {\sr {\Lq }{\to }} \def \eqae {\sr {\rm a.e.}{=}} \def \eqas {\sr {\rm a.s.}{=}} \def \eqd {\sr {\rm d}{=}} \def \approxd {\sr {\rm d}{\approx }} \def \Sa {(S1)\xspace } \def \Sb {(S2)\xspace } \def \Sc {(S3)\xspace } \)

1.4 Conditioning on location

  • Lemma 1.4.1 Let \(X\) be a random variable, and let \(A\sw \R \) be such that \(\P [X\in A]>0\). Then there exists a random variable \(Y\) such that

    • 1. \(\P [Y\in A]=1\).

    • 2. \(\P [Y\in B]=\frac {\P [X\in B]}{\P [X\in A]}\) for all \(B\sw A\). (1.4)

    If \(Y'\) is any random variable satisfying these two conditions then \(Y\eqd Y'\).

  • Definition 1.4.2 The distribution of \(Y\) is known as the ‘conditional distribution of \(X\) given the event \(\{X\in A\}\)’. We write this relationship in symbols as \(Y\eqd X|_{\{X\in A\}}\).

Note that we use \(\eqd \) and not \(=\) in Definition 1.4.2. It is possible to make lots of different random variables \(Y\) that satisfy properties 1 and 2 of Lemma 1.4.1, but they all have the same distribution. Using \(\eqd \) instead of \(=\) captures this fact. We will prove Lemma 1.4.2 shortly, but let us first concentrate on getting the intuition right. Property 1 in Lemma 1.4.1 says that \(Y\) is always inside the set \(A\). Property 2 says that, inside \(A\), \(Y\) behaves like \(X\). (Taking \(B=A\) in property 2 gives property 1, but it will be helpful to refer back to them separately.)

You might like to think of \(Y\) as what happens if the random variable \(X\) is forced to sit inside the set \(A\). It is still (in general) a random quantity, and it reflects exactly the random behaviour of \(X\) inside the set \(A\), but all the behaviour of \(X\) outside of \(A\) is forgotten. Another way to understand \(Y\) is via rejection sampling: we could repeatedly take samples of \(X\) until we obtain a sample of \(X\) that is inside the set \(A\). The random quantity that we obtain from this procedure has precisely the same behaviour as \(Y\).

We will use the usual language of probability to rewrite the event \(\{X\in A\}\) when it is more intuitive to do so. For example, if \(A=[a,b]\) then we might write \(X|_{\{X\in [a,b]\}}\), or if \(A=\{a\}\) then we might write \(X|_{\{X=a\}}\).

  • Example 1.4.3 Suppose that \(X\sim \Normal (0,1)\). The values taken by \(X\) are spread out across the real line. The probability density function of \(X\), given by \(f_X(x)=\frac {1}{\sqrt {2\pi }}e^{-x^2/2}\) allows us to visualize the random location of \(X\):

    (image)

    The random variable \(X\) is more likely to be in locations where \(f_X(x)\) takes larger values, or more precisely \(\P [a\leq X\leq b]=\int _a^b f_X(x)\,dx\), the area under the curve \(f_X\) between \(a\) and \(b\).

    Let \(Y=X|_{\{X\in [0,\infty )\}}\). We can use the properties given in Lemma 1.4.1 to find the distribution of \(Y\), where we take \(A=[0,\infty )\). Firstly, note that property 1 gives \(\P [Y\leq 0]=0\), so \(\P [Y\leq y]=0\) for all \(y\leq 0\). For \(y>0\) we have

    \begin{align} \P [Y\leq y] &=\P [Y\leq 0]+\P [0\leq Y\leq y] \notag \\ &= 0 + \frac {\P [0\leq X\leq y]}{\P [0\leq X<\infty ]} \notag \\ &= \frac {\int _0^y f_X(x)\,dx}{1/2} \label {eq:N12} \\ &=\int _0^y 2\frac {1}{\sqrt {2\pi }}e^{-x^2/2}\,dx. \notag \end{align} We therefore obtain that \(Y\) is a continuous random variable with p.d.f.

    \begin{equation*} f_Y(y)= \begin{cases} 0 & \text { for }y\leq 0 \\ \sqrt {\frac {2}{\pi }}e^{-y^2/2} & \text { for }y>0. \end {cases} \end{equation*}

    Plotting \(f_X\) and \(f_Y\) on the same axis we obtain

    (image)

    Note that \(f_Y(y)\) is zero for \(y\in (-\infty ,0)\), and double the value of \(f_X(y)\) on \(y\in [0,\infty )\). This is not a coincidence. It occurs precisely because \(Y\) retains the ‘same’ randomness as \(X\) inside the set \(A=[0,\infty )\), but \(Y\) can only take values inside the set \(A\), so the p.d.f. within in that segment must be scaled up to ensure that \(\int _\R f_Y(y)\,dy=1\). That fact that this scaling up is by a factor of \(2\), in this example, comes from (1.5) and in particular from \(\P [X\in A]=\frac 12\).

In Problem 1.7 you can explore Example 1.4.3 a bit further, and there is a more general version in Problem 1.8. We will now give a proof of Lemma 1.4.1, based on the idea of rejection sampling that we mentioned below Lemma 1.4.1.

Proof of Lemma 1.4.1: \(\offsyl \) We will discuss this proof in lectures, because Lemma 1.4.1 is fundamental to the whole course and the key ideas of the proof are helpful to understand. The details are less important to us: our focus is on becoming competent practitioners of Bayesian statistics, rather than on becoming able to develop its theory.

Let \(X_1,X_2,\ldots \) be a sequence of i.i.d. copies of the random variable \(X\). Let \(N\in \N \) be the number of the first copy for which \(X_N\in A\). Let us write \(q=\P [X_n\in A]>0\). The events \(\{X_n\in A\}\) are a sequence of independent trials with success probability \(q\), so the number of trials until the first success is \(\Geo (q)\). In particular, since \(\P [\Geo (q)<\infty ]=1\), a success will eventually happen. Let \(N=\min \{n\in \N \-X_n\in A\}\) be the number of trials until this first success.

We claim that \(Y=X_N\) satisfies the two properties required in the statement of the lemma. By definition of \(N\) we have \(\P [X_N\in A]=1\), which shows the first property. To see the second, for \(B\sw A\) we have

\begin{align*} \P [X_N\in B] &= \sum _{n=1}^\infty \P [X_N\in B\text { and }N=n] \\ &= \sum _{n=1}^\infty \P [X_n\in B\text { and }X_{n-1}\notin A, X_{n-2}\notin A,\ldots , X_1\notin A] \\ &= \sum _{n=1}^\infty \P [X_n\in B]\times \P [X_{n-1}\notin A]\times \ldots \times \P [X_1\notin A] \\ &= \sum _{n=1}^\infty \P [X_n\in B](1-q)^{n-1} \\ &= \P [X\in B]\frac {1}{1-q}\sum _{n=1}^\infty (1-q)^{n} \\ &= \P [X\in B]\frac {1}{1-q}\frac {1-q}{q}\\ &= \frac {\P [X\in B]}{\P [X\in A]}. \end{align*} In the above we use independence of the \(X_n\) to deduce the third line. To deduce the fifth line we use that \(X_n\) and \(X\) have the same distribution, hence \(\P [X_n\in B]=\P [X\in B]\), and to deduce the final line we use this same fact with the definition of \(q\). Hence, \(Y=X_N\) satisfies the properties required.

To prove the final part of the lemma, note that if \(Y\) and \(Y'\) both satisfy the two properties then for any \(C\sw \R \) we have

\begin{equation} \label {eq:cond_unique} \P [Y\in C]=\P [Y\in C\cap (\R \sc A)]+\P [Y\in C\cap A]=0+\frac {\P [X\in C\cap A]}{\P [X\in A]} \end{equation}

and the same holds for \(Y'\). To deduce the last equality in (1.6) we have used property 1 for the first term and property 2 for the second term. The right hand side of (1.6) only depends on \(X\), hence \(\P [Y\in C]=\P [Y'\in C]\). Thus \(Y\eqd Y'\).   ∎

  • Lemma 1.4.4 Let \(X\) be a random variable taking values in \(\R ^d\).

    • 1. Let \(a\in \R ^d\) be such that \(\P [X=a]>0\). Then \(X|_{\{X=a\}}\eqd a\).

    • 2. It holds that \(X|_{\R ^d}\eqd X\).

Proof: We should think of these two cases as (1) conditioning on ‘\(X\) is equal to \(a\)’ and (2) conditioning on ‘\(X\) could be anywhere’. The results of doing so should not be a surprise in either case!

To prove the part 1, if we put \(A=\{a\}\) in Lemma 1.4.1 then the first property gives \(\P [X|_{\{X=a\}}=a]=1\). Therefore \(X|_{\{X=a\}}\) and \(a\) are equal (with probability \(1\)) which means they have the same distribution.

To prove part 2, put \(A=\R ^d\) in Lemma 1.4.1, then the second property gives \(\P [Y\in B]=\frac {\P [X\in B]}{\P [X\in \R ^d]}=\frac {\P [X\in B]}{1}=\P [X\in B]\) for all \(B\sw \R ^d\), which tells us that \(\P [X|_{\R ^d}\in B]=\P [X\in B]\). That is, \(X|_{\R ^d}\) and \(X\) have the same distribution.   ∎