You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* update the software stack
* upgrade to sphinx-tojupyter==0.2.0
* update mathjax settings for sphinx4
* re-enable svg version of mathjax
* upgrade to jupyter-book==0.12.1
* update to 2021.11 anaconda
* adjust mathjax config
* configure myst-parser with specified extensions
* add in sans fonts
* try font-manager
* Try and regenerate font-manager
* install basic fonts
* just use standard fonts
* adjustments to prob_meaning lecture
* adjust to letters
Copy file name to clipboardExpand all lines: lectures/prob_meaning.md
+22-30Lines changed: 22 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,17 +65,7 @@ import prettytable as pt
65
65
import matplotlib.pyplot as plt
66
66
from scipy.stats import binom
67
67
import scipy.stats as st
68
-
from matplotlib import rcParams
69
-
from IPython.display import set_matplotlib_formats
70
-
set_matplotlib_formats('retina')
71
68
%matplotlib inline
72
-
73
-
config = {
74
-
"font.family":'serif',
75
-
"mathtext.fontset": 'stix',
76
-
"font.serif": ['SimSun'],
77
-
}
78
-
rcParams.update(config)
79
69
```
80
70
81
71
Empowered with these Python tools, we'll now explore the two meanings described above.
@@ -133,12 +123,12 @@ As usual, a law of large numbers justifies this answer.
133
123
134
124
**Exercise 1:**
135
125
136
-
* (a) Please write a Python class to compute $f_k^I$
126
+
1. Please write a Python class to compute $f_k^I$
137
127
138
-
* (b) Please use your code to compute $f_k^I, k = 0, \ldots , n$ and compare them to
128
+
2. Please use your code to compute $f_k^I, k = 0, \ldots , n$ and compare them to
139
129
$\textrm{Prob}(X = k | \theta)$ for various values of $\theta, n$ and $I$
140
130
141
-
* (c) With the Law of Large numbers in mind, use your code to say something
131
+
3. With the Law of Large numbers in mind, use your code to say something
142
132
143
133
+++
144
134
@@ -360,25 +350,27 @@ a beta distribution with parameters $\alpha, \beta$.
360
350
361
351
**Exercise 2:**
362
352
363
-
* (a) Please write down the **likelihood function** for a sample of length $n$ from a binomial distribution with parameter $\theta$.
353
+
**a)** Please write down the **likelihood function** for a sample of length $n$ from a binomial distribution with parameter $\theta$.
354
+
355
+
**b)** Please write down the **posterior** distribution for $\theta$ after observing one flip of the coin.
364
356
365
-
* (b) Please write down the **posterior** distribution for $\theta$ after observing one flip of the coin.
357
+
**c)** Please pretend that the true value of $\theta = .4$ and that someone who doesn't know this has a beta prior distribution with parameters with $\beta = \alpha = .5$.
366
358
367
-
* (c) Please pretend that the true value of $\theta = .4$ and that someone who doesn't know this has a beta prior distribution with parameters with $\beta = \alpha = .5$.
359
+
**d)** Please write a Python class to simulate this person's personal posterior distribution for $\theta$ for a _single_ sequence of $n$ draws.
368
360
369
-
* (d) Please write a Python class to simulate this person's personal posterior distribution for $\theta$ for a _single_ sequence of $n$ draws.
361
+
**e)** Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
370
362
371
-
* (e) Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
363
+
**f)** For various $n$'s, please describe and compute a Bayesian coverage interval for the interval $[.45, .55]$.
372
364
373
-
* (f) For various $n$'s, please describe and compute a Bayesian coverage interval for the interval $[.45, .55]$.
365
+
**g)** Please tell what question a Bayesian coverage interval answers.
374
366
375
-
* (g) Please tell what question a Bayesian coverage interval answers.
367
+
**h)** Please compute the Posterior probabililty that $\theta \in [.45, .55]$ for various values of sample size $n$.
376
368
377
-
* (h) Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
369
+
**i)** Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
378
370
379
371
**Answer:**
380
372
381
-
* (a) Please write down the **likelihood function** and the **posterior** distribution for $\theta$ after observing one flip of our coin.
373
+
**a)** Please write down the **likelihood function** and the **posterior** distribution for $\theta$ after observing one flip of our coin.
* (e) Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
473
+
**e)** Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
482
474
483
475
```{code-cell} ipython3
484
476
Bay_stat = Bayesian()
@@ -505,7 +497,7 @@ ax.legend(fontsize=11)
505
497
plt.show()
506
498
```
507
499
508
-
* (f) For various $n$'s, please describe and compute $.05$ and $.95$ quantiles for posterior probabilities.
500
+
**f)** For various $n$'s, please describe and compute $.05$ and $.95$ quantiles for posterior probabilities.
509
501
510
502
```{code-cell} ipython3
511
503
upper_bound = [ii.ppf(0.05) for ii in Bay_stat.posterior_list[:14]]
@@ -521,7 +513,7 @@ interval_df
521
513
522
514
As n increases, we can see that Bayesian coverage intervals narrow and move toward $0.4$.
523
515
524
-
* (g) Please tell what question a Bayesian coverage interval answers.
516
+
**g)** Please tell what question a Bayesian coverage interval answers.
525
517
526
518
The Bayesian coverage interval tells the range of $\theta$ that corresponds to the [$p_1$, $p_2$] quantiles of the cumulative probability distribution (CDF) of the posterior distribution.
527
519
@@ -533,7 +525,7 @@ $$
533
525
F(a)=p_1,F(b)=p_2
534
526
$$
535
527
536
-
* (h) Please compute the Posterior probabililty that $\theta \in [.45, .55]$ for various values of sample size $n$.
528
+
**h)** Please compute the Posterior probabililty that $\theta \in [.45, .55]$ for various values of sample size $n$.
537
529
538
530
```{code-cell} ipython3
539
531
left_value, right_value = 0.45, 0.55
@@ -567,7 +559,7 @@ When the number of observations becomes large enough, our Bayesian becomes so co
567
559
568
560
That is why we see a nearly horizontal line when the number of observations exceeds 500.
569
561
570
-
* (i) Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
562
+
**i)** Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
571
563
572
564
Using the Python class we made above, we can see the evolution of posterior distributions as n approaches infinity.
0 commit comments