Skip to content

Commit 60826d6

Browse files
committed
updates
1 parent eba931b commit 60826d6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lectures/imp_sample.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.16.6
7+
jupytext_version: 1.17.1
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -19,7 +19,7 @@ kernelspec:
1919

2020
## Overview
2121

22-
In {doc}`this lecture <likelihood_ratio_process>` we described a peculiar property of a likelihood ratio process, namely, that its mean equals one for all $t \geq 0$ despite its converging to zero almost surely.
22+
In {doc}`likelihood_ratio_process` we described a peculiar property of a likelihood ratio process, namely, that its mean equals one for all $t \geq 0$ despite its converging to zero almost surely.
2323

2424
While it is easy to verify that peculiar property analytically (i.e., in population), it is challenging to use a computer simulation to verify it via an application of a law of large numbers that entails studying sample averages of repeated simulations.
2525

@@ -37,11 +37,14 @@ import matplotlib.pyplot as plt
3737
from jax.scipy.special import gammaln
3838
from typing import NamedTuple
3939
from functools import partial
40+
41+
# Set JAX to use 64-bit floats
42+
jax.config.update("jax_enable_x64", True)
4043
```
4144

4245
## Mathematical expectation of likelihood ratio
4346

44-
In {doc}`this lecture <likelihood_ratio_process>`, we studied a likelihood ratio $\ell \left(\omega_t\right)$
47+
In {doc}`likelihood_ratio_process`, we studied a likelihood ratio $\ell \left(\omega_t\right)$
4548

4649
$$
4750
\ell \left( \omega_t \right) = \frac{f\left(\omega_t\right)}{g\left(\omega_t\right)}
@@ -59,7 +62,7 @@ $$
5962

6063
Our goal is to approximate the mathematical expectation $E \left[ L\left(\omega^t\right) \right]$ well.
6164

62-
In {doc}`this lecture <likelihood_ratio_process>`, we showed that $E \left[ L\left(\omega^t\right) \right]$ equals $1$ for all $t$.
65+
In {doc}`likelihood_ratio_process`, we showed that $E \left[ L\left(\omega^t\right) \right]$ equals $1$ for all $t$.
6366

6467
We want to check out how well this holds if we replace $E$ with sample averages from simulations.
6568

@@ -183,11 +186,16 @@ key = jr.PRNGKey(0)
183186
```
184187

185188
```{code-cell} ipython3
189+
---
190+
mystnb:
191+
figure:
192+
caption: 'Real data generating process $g$ and importance distribution $h$'
193+
name: fig_imp_real
194+
---
186195
w_range = jnp.linspace(1e-5, 1-1e-5, 1000)
187196
188197
plt.plot(w_range, g(w_range), label=f'g=Beta({g_a}, {g_b})')
189198
plt.plot(w_range, beta_pdf(w_range, 0.5, 0.5), label=f'h=Beta({h_a}, {h_b})')
190-
plt.title('real data generating process $g$ and importance distribution $h$')
191199
plt.legend()
192200
plt.ylim([0., 3.])
193201
plt.show()
@@ -450,7 +458,6 @@ plt.plot(w_range, g(w_range), label=f'g=Beta({g_a}, {g_b})')
450458
plt.plot(w_range, beta_pdf(w_range, a_list[0], b_list[0]), label=f'$h_1$=Beta({a_list[0]},{b_list[0]})')
451459
plt.plot(w_range, beta_pdf(w_range, a_list[1], b_list[1]), label=f'$h_2$=Beta({a_list[1]},{b_list[1]})')
452460
plt.plot(w_range, beta_pdf(w_range, a_list[2], b_list[2]), label=f'$h_3$=Beta({a_list[2]},{b_list[2]})')
453-
plt.title('real data generating process $g$ and importance distribution $h$')
454461
plt.legend()
455462
plt.ylim([0., 3.])
456463
plt.show()

0 commit comments

Comments
 (0)