-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprobability.qmd
453 lines (280 loc) · 8.62 KB
/
probability.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# Probability
{{< include shared-config.qmd >}}
---
Most of the content in this chapter should be review from UC Davis Epi 202.
## Statistical events
---
:::{#thm-prob-subset}
If $A$ and $B$ are statistical events and $A\subseteq B$, then $p(A, B) = p(A)$.
:::
---
::: proof
Left to the reader.
:::
## Random variables
### Binary variables {#sec-binary-vars}
{{< include binary-vars.qmd >}}
---
### Count variables {#sec-count-vars}
{{< include count-vars.qmd >}}
---
## Key probability distributions
### The Bernoulli distribution {#sec-bern-dist}
{{< include bernoulli.qmd >}}
---
### The Poisson distribution {#sec-poisson-dist}
{{< include poisson.qmd >}}
---
### The Negative-Binomial distribution {#sec-nb-dist}
{{< include negbinom.qmd >}}
### Weibull Distribution {#sec-weibull}
$$
\begin{aligned}
p(t)&= \alpha\lambda x^{\alpha-1}\text{e}^{-\lambda x^\alpha}\\
h(t)&=\alpha\lambda x^{\alpha-1}\\
S(t)&=\text{e}^{-\lambda x^\alpha}\\
E(T)&= \Gamma(1+1/\alpha)\cdot \lambda^{-1/\alpha}
\end{aligned}
$$
When $\alpha=1$ this is the exponential. When $\alpha>1$ the hazard is
increasing and when $\alpha < 1$ the hazard is decreasing. This provides
more flexibility than the exponential.
We will see more of this distribution later.
## Characteristics of probability distributions
### Probability density function {#sec-prob-dens}
{{< include _def-pdf.qmd >}}
---
:::{#thm-density-vs-CDF}
### Density function is derivative of CDF
The density function $f(t)$ or $\p(T=t)$ for a random variable $T$ at value $t$ is equal to the derivative of the cumulative probability function $F(t) \eqdef P(T\le t)$; that is:
$$f(t) \eqdef \deriv{t} F(t)$$
:::
---
:::{#thm-density-sums-to-one}
#### Density functions integrate to 1
For any density function $f(x)$,
$$\int_{x \in \rangef{X}} f(x) dx = 1$$
:::
---
### Hazard function {#sec-prob-haz}
{{< include _def-hazard.qmd >}}
---
### Expectation {#sec-expectation}
:::{#def-expectation}
### Expectation, expected value, population mean \index{expectation} \index{expected value}
The **expectation**, **expected value**, or **population mean** of a *continuous* random variable $X$, denoted $\E{X}$, $\mu(X)$, or $\mu_X$, is the weighted mean of $X$'s possible values, weighted by the probability density function of those values:
$$\E{X} = \int_{x\in \rangef{X}} x \cdot \p(X=x)dx$$
The **expectation**, **expected value**, or **population mean** of a *discrete* random variable $X$, denoted $\E{X}$, $\mu(X)$, or $\mu_X$, is the mean of $X$'s possible values, weighted by the probability mass function of those values:
$$\E{X} = \sum_{x \in \rangef{X}} x \cdot \P(X=x)$$
(c.f. <https://en.wikipedia.org/wiki/Expected_value>)
:::
---
:::{#thm-bernoulli-mean}
#### Expectation of the Bernoulli distribution
The expectation of a Bernoulli random variable with parameter $\pi$ is:
$$\E{X} = \pi$$
:::
---
:::{.proof}
$$
\ba
\E{X}
&= \sum_{x\in \rangef{X}} x \cd \P(X=x)
\\&= \sum_{x\in \set{0,1}} x \cd \P(X=x)
\\&= \paren{0 \cd \P(X=0)} + \paren{1 \cd \P(X=1)}
\\&= \paren{0 \cd (1-\pi)} + \paren{1 \cd \pi}
\\&= 0 + \pi
\\&= \pi
\ea
$$
:::
---
### Variance and related characteristics
:::{#def-variance}
#### Variance
The variance of a random variable $X$ is the expectation of the squared difference between $X$ and $\E{X}$; that is:
$$
\Var{X} \eqdef \E{(X-\E{X})^2}
$$
:::
---
:::{#thm-variance}
#### Simplified expression for variance
$$\Var{X}=\E{X^2} - \sqf{\E{X}}$$
---
::::{.proof}
By linearity of expectation, we have:
$$
\begin{aligned}
\Var{X}
&\eqdef \E{(X-\E{X})^2}\\
&=\E{X^2 - 2X\E{X} + \sqf{\E{X}}}\\
&=\E{X^2} - \E{2X\E{X}} + \E{\sqf{\E{X}}}\\
&=\E{X^2} - 2\E{X}\E{X} + \sqf{\E{X}}\\
&=\E{X^2} - \sqf{\E{X}}\\
\end{aligned}
$$
::::
:::
---
::: {#def-precision}
#### Precision
The **precision** of a random variable $X$, often denoted $\tau(X)$, $\tau_X$, or shorthanded as $\tau$, is
the inverse of that random variable's variance; that is:
$$\tau(X) \eqdef \inv{\Var{X}}$$
:::
::: {#def-sd}
#### Standard deviation
The standard deviation of a random variable $X$ is the square-root of the variance of $X$:
$$\SD{X} \eqdef \sqrt{\Var{X}}$$
:::
---
:::{#def-cov}
#### Covariance
For any two one-dimensional random variables, $X,Y$:
$$\Cov{X,Y} \eqdef \Expf{(X - \E X)(Y - \E Y)}$$
:::
---
:::{#thm-alt-cov}
$$\Cov{X,Y}= \E{XY} - \E{X} \E{Y}$$
:::
---
:::{.proof}
Left to the reader.
:::
---
:::{#lem-cov-xx}
##### The covariance of a variable with itself is its variance
For any random variable $X$:
$$\Cov{X,X} = \Var{X}$$
:::
:::{.proof}
$$
\ba
\Cov{X,X} &= E[XX] - E[X]E[X]
\\ &= E[X^2]-(E[X])^2
\\ &= \Var{X}
\ea
$$
:::
---
:::{#def-cov-vec-x}
#### Variance/covariance of a $p \times 1$ random vector
For a $p \times 1$ dimensional random vector $X$,
$$
\begin{aligned}
\text{Var}(X)
&\eqdef \text{Cov}(X)\\
&\eqdef E[ \left( X - E\lbrack X\rbrack \right)^{\top}\left( X - E\lbrack X\rbrack \right) ]\\
\ea
$$
:::
---
:::{#thm-vcov-vec}
#### Alternate expression for variance of a random vector
$$
\ba
\Var{X}
&= E[ X^{\top}X ] - {E\lbrack X\rbrack}^{\top}E\lbrack X\rbrack
\end{aligned}
$$
:::
---
:::{.proof}
$$
\ba
\Var{X}
&= E[ \left( X^{\top} - E\lbrack X\rbrack^{\top} \right)\left( X - E\lbrack X\rbrack \right) ]\\
&= E[ X^{\top}X - E\lbrack X\rbrack^{\top}X - X^{\top}E\lbrack X\rbrack + E\lbrack X\rbrack^{\top}E\lbrack X\rbrack ]\\
&= E[ X^{\top}X ] - E\lbrack X\rbrack^{\top}E\lbrack X\rbrack - {E\lbrack X\rbrack}^{\top}E\lbrack X\rbrack + E\lbrack X\rbrack^{\top}E\lbrack X\rbrack\\
&= E[ X^{\top}X ] - 2{E\lbrack X\rbrack}^{\top}E\lbrack X\rbrack + E\lbrack X\rbrack^{\top}E\lbrack X\rbrack\\
&= E[ X^{\top}X ] - {E\lbrack X\rbrack}^{\top}E\lbrack X\rbrack
\end{aligned}
$$
:::
---
:::{#thm-var-lincom}
#### Variance of a linear combination
For any set of random variables $\Xin$ and corresponding constants $a_1, ... ,a_n$:
$$\Var{\sumin a_i X_i} = \sumin \sumn{j} a_i a_j \Cov{X_i,X_j}$$
:::
---
:::{.proof}
Left to the reader...
:::
---
:::{#lem-var-lincom2}
For any two random variables $X$ and $Y$ and scalars $a$ and $b$:
$$\Var{aX + bY} = a^2 \Var{X} + b^2 \Var{Y} + 2(a \cd b) \Cov{X,Y}$$
:::
---
:::{.proof}
Apply @thm-var-lincom with $n=2$, $X_1 = X$, and $X_2 = Y$.
Or, see <https://statproofbook.github.io/P/var-lincomb.html>
:::
---
:::{#def-homosked}
### homoskedastic, heteroskedastic
A random variable $Y$ is **homoskedastic** (with respect to covariates $X$) if the variance of $Y$ does not vary with $X$:
$$\Varr(Y|X=x) = \ss, \forall x$$
Otherwise it is **heteroskedastic**.
:::
---
:::{#def-indpt}
### Statistical independence
A set of random variables $\X1n$ are **statistically independent**
if their joint probability is equal to the product of their marginal probabilities:
$$\Pr(\Xx1n) = \prodi1n{\Pr(X_i=x_i)}$$
:::
::: notes
::::{.callout-tip}
The symbol for independence, $\ind$, is essentially just $\prod$ upside-down.
So the symbol can remind you of its definition (@def-indpt).
::::
:::
---
:::{#def-cind}
### Conditional independence
A set of random variables $\dsn{Y}$ are **conditionally statistically independent**
given a set of covariates $\X1n$
if the joint probability of the $Y_i$s given the $X_i$s is equal to
the product of their marginal probabilities:
$$\Pr(\dsvn{Y}{y}|\dsvn{X}{x}) = \prodi1n{\Pr(Y_i=y_i|X_i=x_i)}$$
:::
---
:::{#def-ident}
#### Identically distributed
A set of random variables $\X1n$ are **identically distributed**
if they have the same range $\rangef{X}$ and if
their marginal distributions $\P(X_1=x_1), ..., \P(X_n=x_n)$ are all
equal to some shared distribution $\P(X=x)$:
$$
\forall i\in \set{1:n}, \forall x \in \rangef{X}: \P(X_i=x) = \P(X=x)
$$
:::
---
:::{#def-cident}
#### Conditionally identically distributed
A set of random variables $\dsn{Y}$ are **conditionally identically distributed**
given a set of covariates $\X1n$
if $\dsn{Y}$ have the same range $\rangef{X}$ and if
the distributions $\P(Y_i=y_i|X_i =x_i)$ are all
equal to the same distribution $\P(Y=y|X=x)$:
$$
\P(Y_i=y|X_i=x) = \P(Y=y|X=x)
$$
:::
---
:::{#def-iid}
#### Independent and identically distributed
A set of random variables $\dsn{X}$ are **independent and identically distributed**
(shorthand: "$X_i\ \iid$") if they are statistically independent and identically distributed.
:::
---
:::{#def-iid}
#### Conditionally independent and identically distributed
A set of random variables $\dsn{Y}$ are **conditionally independent and identically distributed** (shorthand: "$Y_i | X_i\ \ciid$" or just "$Y_i |X_i\ \iid$") given a set of covariates $\dsn{X}$
if $\dsn{Y}$ are conditionally independent given $\dsn{X}$ and $\dsn{Y}$ are identically distributed given
$\dsn{X}$.
:::
{{< include sec-CLT.qmd >}}