Skip to content

Commit 48a3e9b

Browse files
Tom's edits of likelihoods and Bayesian learning lecture
1 parent 003c9f0 commit 48a3e9b

File tree

1 file changed

+77
-40
lines changed

1 file changed

+77
-40
lines changed

lectures/likelihood_bayes.md

Lines changed: 77 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,7 @@ kernelspec:
2020

2121
# Likelihood Ratio Processes and Bayesian Learning
2222

23-
```{contents} Contents
24-
:depth: 2
25-
```
2623

27-
```{code-cell} ipython
28-
%matplotlib inline
29-
import matplotlib.pyplot as plt
30-
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
31-
import numpy as np
32-
from numba import vectorize, njit
33-
from math import gamma
34-
```
3524

3625
## Overview
3726

@@ -50,9 +39,33 @@ today's realization of the likelihood ratio process.
5039
We'll study how, at least in our setting, a Bayesian eventually learns the probability distribution that generates the data, an outcome that
5140
rests on the asymptotic behavior of likelihood ratio processes studied in {doc}`this lecture <likelihood_ratio_process>`.
5241

42+
We'll also drill down into the psychology of our Bayesian learner and study dynamics under his subjective beliefs.
43+
5344
This lecture provides technical results that underly outcomes to be studied in {doc}`this lecture <odu>`
5445
and {doc}`this lecture <wald_friedman>` and {doc}`this lecture <navy_captain>`.
5546

47+
We'll begin by loading some Python modules.
48+
49+
```{code-cell} ipython3
50+
:hide-output: false
51+
52+
%matplotlib inline
53+
import matplotlib.pyplot as plt
54+
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
55+
import numpy as np
56+
from numba import vectorize, njit
57+
from math import gamma
58+
import pandas as pd
59+
60+
import seaborn as sns
61+
colors = sns.color_palette()
62+
63+
@njit
64+
def set_seed():
65+
np.random.seed(142857)
66+
set_seed()
67+
```
68+
5669
## The Setting
5770

5871
We begin by reviewing the setting in {doc}`this lecture <likelihood_ratio_process>`, which we adopt here too.
@@ -370,13 +383,21 @@ a Bayesian's posteior probabilty that nature has drawn history $w^t$ as repeated
370383
$g$.
371384

372385

373-
INSERT NEW BEGINS
374386

375-
### Behavior of posterior probabilities $\{\pi_t\}$ under the subjective probability distribution
376387

388+
## Behavior of posterior probability $\{\pi_t\}$ under the subjective probability distribution
389+
390+
391+
We'll end this lecture by briefly studying what our Baysian learner expects to learn under the
392+
subjective beliefs $\pi_t$ cranked out by Bayes' law.
377393

394+
This will provide us with some perspective on our application of Bayes's law as a theory of learning.
378395

379-
#### A perspective on Bayes's law as a theory of learning
396+
As we shall see, at each time $t$, the Bayesian learner knows that he will be surprised.
397+
398+
But he expects that new information will not lead him to change his beliefs.
399+
400+
And it won't on average under his subjective beliefs.
380401

381402
We'll continue with our setting in which a McCall worker knows that successive
382403
draws of his wage are drawn from either $F$ or $G$, but does not know which of these two distributions
@@ -397,7 +418,7 @@ We assume that the workers also knows the laws of probability theory.
397418
A respectable view is that Bayes' law is less a theory of learning than a statement about the consequences of information inflows for a decision maker who thinks he knows the truth (i.e., a joint probability distribution) from the beginning.
398419

399420

400-
#### Mechanical details again
421+
### Mechanical details again
401422

402423
At time $0$ **before** drawing a wage offer, the worker attaches probability $\pi_{-1} \in (0,1)$ to the distribution being $F$.
403424

@@ -423,16 +444,15 @@ More generally, after making the $t$th draw and having observed $w_t, w_{t-
423444
the probability that $w_{t+1}$ is being drawn from distribution $F$ is
424445

425446
$$
426-
\pi_t = \pi_t(w_t | \pi_{t-1}) \equiv { \pi_{t-1} f(w_t)/g(w_t) \over \pi_{t-1} f(w_t)/g(w_t) + (1-\pi_{t-1})} \tag{44}
427-
$$
447+
\pi_t = \pi_t(w_t | \pi_{t-1}) \equiv { \pi_{t-1} f(w_t)/g(w_t) \over \pi_{t-1} f(w_t)/g(w_t) + (1-\pi_{t-1})}
448+
$$ (eq:like44)
428449
429450
430451
or
431452
432453
433-
<a id='equation-eq-recur1'></a>
434454
$$
435-
\pi_t=\frac{\pi_{t-1} l_t(w_t)}{\pi_{t-1} l_t(w_t)+1-\pi_{t-1}} \tag{56.1}
455+
\pi_t=\frac{\pi_{t-1} l_t(w_t)}{\pi_{t-1} l_t(w_t)+1-\pi_{t-1}}
436456
$$
437457
438458
@@ -480,17 +500,19 @@ ${\textrm{Prob}} \Omega$ and then generating a single realization (or _simulatio
480500
The limit points of $\{\pi_t(\omega)\}_{t=0}^\infty$ as $t \rightarrow +\infty$ are realizations of a random variable that is swept out as we sample $\omega$ from $\Omega$ and construct repeated draws of $\{\pi_t(\omega)\}_{t=0}^\infty$.
481501
482502
483-
By staring at law of motion (44) or (56), we can figure out some things about the probability distribution of the limit points
503+
By staring at law of motion {eq}`eq_recur1` or {eq}`eq:like44` , we can figure out some things about the probability distribution of the limit points
504+
505+
484506
485507
$$
486-
\pi_\infty(\omega) = \lim_{\rightarrow + \infty} \pi_t(\omega).
508+
\pi_\infty(\omega) = \lim_{t \rightarrow + \infty} \pi_t(\omega).
487509
$$
488510
489511
490512
491513
492514
Evidently, since the likelihood ratio $\ell(w_t) $ differs from $1$ when $f \neq g$,
493-
as we have assumed, the only possible fixed points of (44) are
515+
as we have assumed, the only possible fixed points of {eq}`eq:like44` are
494516
495517
$$
496518
\pi_\infty(\omega) =1
@@ -555,7 +577,7 @@ converge pointwise to $0$.
555577
556578
557579
558-
#### Some simulations
580+
### Some simulations
559581
560582
Let's watch the martingale convergence theorem at work in some simulations of our learning model under the worker's subjective distribution.
561583
@@ -615,6 +637,8 @@ T = 200
615637
π_path, w_path = martingale_simulate(π0=π0, T=T, N=10000)
616638
```
617639
640+
641+
618642
```{code-cell} ipython3
619643
fig, ax = plt.subplots()
620644
for i in range(100):
@@ -625,16 +649,8 @@ ax.set_ylabel('$\pi_t$')
625649
plt.show()
626650
```
627651
628-
```{code-cell} ipython3
629-
fig, ax = plt.subplots()
630-
for t in [1, 10, T-1]:
631-
ax.hist(π_path[:,t], bins=20, alpha=0.4, label=f'T={t}')
632-
633-
ax.set_ylabel('count')
634-
ax.set_xlabel('$\pi_T$')
635-
ax.legend(loc='upper right')
636-
plt.show()
637-
```
652+
Now let's plot two paths of pairs of $\{\pi_t, w_t\}$ sequences, one in which $\pi_t \rightarrow 1$,
653+
another in which $\pi_t \rightarrow 0$.
638654
639655
```{code-cell} ipython3
640656
fig, ax = plt.subplots()
@@ -650,33 +666,54 @@ ax2.set_ylabel("$w_t$")
650666
plt.show()
651667
```
652668
669+
670+
Let's plot histograms of $\pi_t$ for various values of $t$.
671+
672+
```{code-cell} ipython3
673+
fig, ax = plt.subplots()
674+
for t in [1, 10, T-1]:
675+
ax.hist(π_path[:,t], bins=20, alpha=0.4, label=f'T={t}')
676+
677+
ax.set_ylabel('count')
678+
ax.set_xlabel('$\pi_T$')
679+
ax.legend(loc='upper right')
680+
plt.show()
681+
```
682+
683+
684+
The above graphs display how the distribution of $\pi_t$ across realizations are moving toward
685+
limit points that we described above and that put all probability either on $0$ or on $1$.
686+
687+
688+
653689
Now let's use our Python code to generate a table that checks out our earlier claims about the
654690
probability distribution of the pointwise limits $\pi_{\infty}(\omega)$.
655691
656692
We'll use our simulations to generate a histogram of this distribution.
657693
694+
In the following table, the left column in bold face reports an assumed value of $\pi_{-1}$.
695+
696+
The second column reports the fraction of $N = 10000$ simulations for which $\pi_{t}$ had converged to $0$ at the terminal date $T=500$ for each simulation.
697+
698+
The third column reports the fraction of $N = 10000$ simulations for which $\pi_{t}$ had converged to $1$ as the terminal date $T=500$ for each simulation.
699+
658700
```{code-cell} ipython3
659701
# create table
660702
table = create_table(list(np.linspace(0,1,11)), N=10000, T=500)
661703
table
662704
```
705+
The fraction of simulations for which $\pi_{t}$ had converged to $1$ is indeed always close to $\pi_{-1}$, as anticipated.
663706
664707
665708
666709
667710
668711
669712
670-
INSERT NEW ENDS
671-
672-
673-
674713
675714
676715
## Sequels
677716
678-
This lecture has been devoted to building some useful infrastructure.
679-
680-
We'll build on results highlighted in this lectures to understand inferences that are the foundations of
717+
This lecture has been devoted to building some useful infrastructure that will help us understand inferences that are the foundations of
681718
results described in {doc}`this lecture <odu>` and {doc}`this lecture <wald_friedman>` and {doc}`this lecture <navy_captain>`.
682719

0 commit comments

Comments
 (0)