forked from dccuchile/CC6104
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_4_ST-prob.tex
1713 lines (1168 loc) · 46.3 KB
/
1_4_ST-prob.tex
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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%\documentclass[mathserif]{beamer}
\documentclass[handout]{beamer}
%\usetheme{Goettingen}
\usetheme{Warsaw}
%\usetheme{Singapore}
%\usetheme{Frankfurt}
%\usetheme{Copenhagen}
%\usetheme{Szeged}
%\usetheme{Montpellier}
%\usetheme{CambridgeUS}
%\usecolortheme{}
%\setbeamercovered{transparent}
\usepackage[english, activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage{dsfont}
\usepackage{graphics}
\usepackage{cases}
\usepackage{graphicx}
\usepackage{pgf}
\usepackage{epsfig}
\usepackage{amssymb}
\usepackage{multirow}
\usepackage{amstext}
\usepackage[ruled,vlined,lined]{algorithm2e}
\usepackage{amsmath}
\usepackage{epic}
\usepackage{fontenc}
\usepackage{framed,color}
\usepackage{palatino, url, multicol}
\usepackage{listings}
%\algsetup{indent=2em}
\vspace{-0.5cm}
\title{Probability}
\vspace{-0.5cm}
\author[Felipe Bravo Márquez]{\footnotesize
%\author{\footnotesize
\textcolor[rgb]{0.00,0.00,1.00}{Felipe José Bravo Márquez}}
\date{ \today }
\begin{document}
\begin{frame}
\titlepage
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Probability and Statistics}
\scriptsize{
\begin{itemize}
\item Probability is the language of \textbf{uncertainty} that is also the basis for statistical inference \cite{poldrack2019statistical}.
\item It forms an important part of the foundation for statistics, because it provides us with the mathematical tools to describe uncertain events.
\item The study of probability arose in part due to interest in understanding games of chance, like cards or dice.
\item These games provide useful examples of many statistical concepts, because when we repeat these games the likelihood of different outcomes remains (mostly) the same.
\end{itemize}
\begin{figure}[h!]
\centering
\includegraphics[scale=0.2]{pics/gambling.png}
\end{figure}
}
\end{frame}
\begin{frame}{Probability and Statistics}
\scriptsize{
\begin{itemize}
\item The problem studied in probability is: given a data generating process, which are the properties of the outputs?
\item The problem studied in statistical inference, data mining and machine learning is: given the outputs, what can we say about the process that generates the observed data?
\end{itemize}
}
\begin{figure}[h!]
\centering
\includegraphics[scale=0.3]{pics/probandstats.png}
\end{figure}
\footnotemark{Figure taken from \cite{wasserman2013all}}
\end{frame}
\begin{frame}\frametitle{What is Probability?}
\scriptsize{
\begin{itemize}
\item We think of probability as a number that describes the likelihood of some event occurring, which ranges from zero (impossibility) to one (certainty).
\item Probabilities can also be expressed in percentages: when the weather forecast predicts a twenty percent chance of rain today.
\item In each case, these numbers are expressing how likely that particular event is, ranging from absolutely impossible to absolutely certain.
\end{itemize}
}
\end{frame}
\begin{frame}\frametitle{Probability Concepts}
\scriptsize{
\begin{itemize}
\item A \textbf{random experiment} in the act of measuring a process whose output is uncertain.
\item Examples: flipping a coin, rolling a 6-sided die, or trying a new route to work to see if it’s faster than the old route.
\item The set with all possible outputs of a random experiment is the \textbf{sample space} $\Omega$ (it can be discrete or continuous).
\item For a coin flip $\Omega = \{$heads, tails$\}$, for the 6-sided die $\Omega = \{1,2,3,4,5,6\}$, and for the amount of time it takes to get to work $\Omega$ is all possible real numbers greater than zero.
\item An \textbf{event} $E \subseteq \Omega$ corresponds to a subset of those outputs.
\item For example, $E = \{ 2,4,6 \}$ is the event of observing an even number when rolling a die.
\end{itemize}
}
\end{frame}
\begin{frame}\frametitle{Probability}
\begin{scriptsize}
\begin{itemize}
\item Now we can outline the formal features of a probability, which were first defined by the Russian mathematician Andrei Kolmogorov.
\begin{figure}[h!]
\centering
\includegraphics[scale=0.15]{pics/kolmogorov.jpeg}
\end{figure}
\item A probability $\mathbb{P}$ is a real-valued function defined over $\Omega$ that satisfies the following properties:
\end{itemize}
\begin{block}{Properties}
\begin{enumerate}
\item For any event $E \subseteq \Omega$ , $0 \leq \mathbb{P}(E) \leq 1$.
\item The probability of the sample space is 1: $\mathbb{P}(\Omega) =1$
\item Let $E_{1},E_{2},\dots,E_{k} \in \Omega$ be disjoint sets
\begin{displaymath}
\mathbb{P}(\bigcup_{i=1}^{k}E_{i}) = \sum_{i}^{k}P(E_{i})
\end{displaymath}
\end{enumerate}
\end{block}
Probabilities cannot be negative or greater than 1.
\end{scriptsize}
\end{frame}
\begin{frame}\frametitle{Interpretation of Probabilities}
\begin{scriptsize}
The are two common interpretations of probabilities: frequencies and degrees of beliefs (or Bayesian probabilities).
\begin{block}{Frequentist probability}
\begin{itemize}
\item In the frequency interpretation, $\mathbb{P}(E)$ is the long run proportion (limiting frequency) of times that $E$ is true in repetitions.\footnote{\url{https://en.wikipedia.org/wiki/Frequentist_probability}}
\item For example, if we say that the probability of heads is 1/2, we mean that if we flip the coin many times then the proportion of times we get heads tends to 1/2 as the number of tosses increases.
\item When the sample space $\Omega$ is finite, we can say that
\begin{displaymath}
\mathbb{P}(E) = \frac{\text{Favorable cases}}{\text{total cases}} = \frac{|E|}{|\Omega|}
\end{displaymath}
\end{itemize}
\end{block}
\end{scriptsize}
\end{frame}
\begin{frame}\frametitle{Interpretation of Probabilities}
\begin{scriptsize}
\begin{block}{Probability as a degree of belief}
\begin{itemize}
\item The degree-of-belief interpretation (a.k.a Bayesian interpretation or Subjective interpretation) is that $\mathbb{P}(E)$ measures an observer's strength of belief that $E$ is true.
\item If I were to ask you ``How likely is it that the US will return to the moon by 2026'', you can provide an answer to this question based on your knowledge and beliefs.
\item Even though there are no relevant frequencies to compute a frequentist probability.
\end{itemize}
\end{block}
\begin{itemize}
\item In either interpretation, we require that properties 1 to 3 hold.
\item The difference in interpretation will not matter much until we deal with statistical inference.
\item There, the differing interpretations lead to two schools of inference: the frequentist and the Bayesian schools.
\end{itemize}
\end{scriptsize}
\end{frame}
\begin{frame}\frametitle{The rule of subtraction}
\scriptsize{
\begin{itemize}
\item The probability of some event $E$ not happening is one minus the probability of the event happening:
\begin{displaymath}
\mathbb{P}(\neg E) = 1 - \mathbb{P}(E)
\end{displaymath}
\item For example, if the probability of rolling a one in a single die throw is 1/6, then the probability of rolling anything other than a one is 5/6.
\end{itemize}
}
\end{frame}
\begin{frame}\frametitle{Combinatorial methods}
\begin{scriptsize}
\begin{itemize}
\item There are a few facts from counting theory that are useful for calculating probabilities.
\item Given $n$ objects, the number of ways of ordering these objects is $n!=n(n-1)(n-2)\cdots3\cdot2\cdot1$.
\item For convenience, we define $0!=1$.
\item We also define
\begin{displaymath}
{n \choose k} = \frac{n!}{k!(n-k)!}
\end{displaymath}
read ``n choose k'', which is the number of distinct ways of choosing k objects from n.
\end{itemize}
\end{scriptsize}
\end{frame}
\begin{frame}[fragile]\frametitle{Combinatorial methods}
\begin{scriptsize}
\begin{itemize}
\item For example, if we have a class of 20 people and we want to select a committee of 3 students, then there are
\begin{displaymath}
{20 \choose 3} = \frac{20!}{3!17!}=1140
\end{displaymath}
possible committees.
\item In R:
\begin{verbatim}
> factorial(20)/(factorial(3)*factorial(17))
[1] 1140
> choose(20,3)
[1] 1140
\end{verbatim}
\item We note the following properties:
\begin{displaymath}
{n \choose 0} = {n \choose n}=1
\end{displaymath}
and
\begin{displaymath}
{n \choose k} = {n \choose n-k}.
\end{displaymath}
\begin{verbatim}
> choose(20,17)
[1] 1140
\end{verbatim}
\end{itemize}
\end{scriptsize}
\end{frame}
\begin{frame}{Conditional Probabilities}
\scriptsize{
\begin{itemize}
\item The \textbf{conditional probability} for $Y$ given $X$ is defined as:
\begin{displaymath}
\mathbb{P}(Y|X) = \frac{\mathbb{P}(X,Y)}{\mathbb{P}(X)}
\end{displaymath}
\item $\mathbb{P}(Y|X)$ can be interpreted as the fraction of times $Y$ occurs when $X$ is known to occur.
\item If $X$ and $Y$ are independent $\mathbb{P}(Y|X)=\mathbb{P}(Y)$
\end{itemize}
\begin{block}{Example}
\begin{itemize}
\item In the experiment of rolling a fair die, let G be the event of getting and outcome greater than 2 ($G=\{3,4,5,6\}$) and O the event of getting an odd number ($O=\{1,3,5\}$).
\item What is the value of $\mathbb{P}(G|O)$?
\end{itemize}
\end{block}
}
\end{frame}
\begin{frame}{Conditional Probabilities}
\scriptsize{
\begin{itemize}
\item Using the definition that $\mathbb{P}(X)=\frac{\text{Favorable cases}}{\text{total cases}}$: $\mathbb{P}(G)=4/6$, $\mathbb{P}(O)=3/6$, and $\mathbb{P}(G|O)= 2/3.$
\item Notice that once we know O, the number of favourable cases for G was reduced to $\{3,5\}$ and the total number of cases to $\{1,3,5\}$.
\item Now, according to the definition above $\mathbb{P}(G|O) = \frac{\mathbb{P}(G,O)}{\mathbb{P}(O)}$.
\item Where $\mathbb{P}(G,O) = 2/6$ (favourable cases correspond to the intersection between G and O $\{3,5\}$).
\item So, $\mathbb{P}(G|O) = \frac{\mathbb{P}(G,O)}{\mathbb{P}(O)}=\frac{2/6}{3/6}=2/3$.
\end{itemize}
\begin{block}{Warning}
\begin{itemize}
\item In general it is not the case that $\mathbb{P}(Y|X) = \mathbb{P}(X|Y)$.
\item People get this confused all the time.
\item For example, the probability of spots given you have measles is 1 but the probability that you have measles given that you have spots is not 1.
\item In this case, the difference between $\mathbb{P}(Y|X)$ and $\mathbb{P}(X|Y)$ is obvious but there are cases where it is less obvious.
\end{itemize}
\end{block}
}
\end{frame}
\begin{frame}[fragile]{Conditional Probabilities: Example}
\scriptsize{
\begin{itemize}
\item A medical test for a disease D has outcomes ``positive'' and ``negative'', the probabilities are:
\begin{center}
\begin{tabular}{c|cc}
& D & $\neg$ D \\ \hline
positive & 0.009 & 0.099 \\
negative & 0.001 & 0.891 \\
\end{tabular}
\end{center}
\item From the definition of conditional probability
\begin{displaymath}
\mathbb{P}(\text{positive}|D) = \frac{\mathbb{P}(\text{positive},D)}{\mathbb{P}(D)} = \frac{0.009}{0.009+0.001} = 0.9
\end{displaymath}
\begin{verbatim}
> pos.d <- 0.009/(0.009+0.001)
> pos.d
[1] 0.9
\end{verbatim}
and
\begin{displaymath}
\mathbb{P}(\text{negative}|\neg D) = \frac{\mathbb{P}(\text{negative},\neg D)}{\mathbb{P}(\neg D)} = \frac{0.891}{0.891+0.0991} \approx 0.9
\end{displaymath}
\begin{verbatim}
> neg.notd <- 0.891/(0.891+0.0991)
> neg.notd
[1] 0.8999091
\end{verbatim}
\end{itemize}
}
\end{frame}
\begin{frame}[fragile]{Conditional Probabilities: Example}
\scriptsize{
\begin{itemize}
\item Apparently, the test is fairly accurate.
\item Sick people yield a positive 90 percent of the time and healthy people yield a negative about 90 percent of the time.
\item Suppose you go for a test and get a positive.
\item What is the probability you have the disease? Most people answer $0.90$.
\item The correct answer is
\begin{displaymath}
\mathbb{P}(D|\text{positive}) = \frac{\mathbb{P}(D,\text{positive})}{\mathbb{P}(\text{positive})} = \frac{0.009}{0.009+0.099} \approx 0.08
\end{displaymath}
\begin{verbatim}
> d.pos <- 0.009/(0.009+0.099)
> d.pos
[1] 0.08333333
\end{verbatim}
\item The lesson here is that you need to compute the answer numerically.
\item Don't trust your intuition.
\end{itemize}
}
\end{frame}
\begin{frame}{Bayes' Theorem and Total Probabilities}
\scriptsize{
\begin{itemize}
\item The conditional probability $\mathbb{P}(Y|X)$ and $\mathbb{P}(X|Y)$ can be expressed as a function of each other using Bayes' theorem.
\begin{displaymath}
\mathbb{P}(Y|X)=\frac{\mathbb{P}(X|Y)\mathbb{P}(Y)}{\mathbb{P}(X)}
\end{displaymath}
\item Then let $\{ Y_1,Y_2,\dots, Y_k \} $ be a set of mutually exclusive events of the sample space of a R.V $X$, the denominator of Bayes' theorem can be expressed as:
\begin{displaymath}
\mathbb{P}(X)= \sum_{i=1}^{k} \mathbb{P}(X,Y_i) = \sum_{i=1}^{k} \mathbb{P}(X|Y_i)\mathbb{P}(Y_i)
\end{displaymath}
\end{itemize}
}
\end{frame}
\begin{frame}{Example}
\scriptsize{
\begin{itemize}
\item I split my emails into three categories: $A_1$=```spam'', $A_2$=```low priority'', $A_3$=```high priority''.'
\item We know that $\mathbb{P}(A_1)=0.7$, $\mathbb{P}(A_2)=0.2$ and $\mathbb{P}(A_3)=0.1$, clearly $0.7+0.2+0.1=1$.
\item Let $B$ be the event that the mail contains the word ``free''.
\item We know that $\mathbb{P}(B|A_1)=0.9$ $\mathbb{P}(B|A_2)=0.01$ y $\mathbb{P}(B|A_3)=0.01$ clearly $0.9+0.01+0.01 \neq 1$
\item What is the probability that an email with the word ``free'' in it is ``spam''?
\item Using Bayes:
\begin{displaymath}
\mathbb{P}(A_1|B) = \frac{\mathbb{P}(B|A_1)\times \mathbb{P}(A_1)}{\mathbb{P}(B)} = \frac{0.9 \times 0.7}{\mathbb{P}(B)} = \frac{0.63}{\mathbb{P}(B)}
\end{displaymath}
\end{itemize}
}
\end{frame}
\begin{frame}[fragile]{Example}
\scriptsize{
\begin{itemize}
\item Using Total Probabilities:
\begin{eqnarray*}
\mathbb{P}(B) & = & \mathbb{P}(B|A_1)\times\mathbb{P}(A_1)+\mathbb{P}(B|A_2)\times\mathbb{P}(A_2)+\mathbb{P}(B|A_3)\times\mathbb{P}(A_3) \\
& = & 0.9 \times 0.7 + 0.01 \times 0.2 + 0.01 \times 0.1 = 0.633
\end{eqnarray*}
Finally,
\begin{displaymath}
\mathbb{P}(A_1|B) = \frac{0.63}{0.633} = 0.995
\end{displaymath}
\item In R:
\begin{verbatim}
> a1 <-0.7
> a2 <- 0.2
> a3 <-0.1
> b.a1 <- 0.9
> b.a2<-0.01
> b.a3<-0.01
> b<-b.a1*a1+b.a2*a2+b.a3*a3
> a1.b<-b.a1*a1/b
> a1.b
[1] 0.9952607
\end{verbatim}
\end{itemize}
}
\end{frame}
\begin{frame}{Random Variable}
\scriptsize{
\begin{itemize}
\item A \textbf{random variable} is a mapping (or function)
\begin{displaymath}
X: \Omega \rightarrow \mathbb{R}
\end{displaymath}
which assigns a real value $X(e)$ to any event of $\Omega$.
\item Example: We flip a fair coin 10 times. The outcome of each toss is a head $H$ or a tail $T$.
\item Let $X(e)$ be the number of heads in the sequence of outcomes.
\begin{itemize}
\item If $e=HHTHHTHHTT$, then $X(e)=6$
\end{itemize}
\end{itemize}
}
\end{frame}
\begin{frame}{Random Variable}
\scriptsize{
\begin{itemize}
\item A random variable can in many cases be the identity function.
\item Example, if we roll a 6-sided die once and $X(e)$ is the resulting die value, then $X(e)=e$, for $e \in \{1,2,3,4,5,6\}$.
\item In these cases, the notion that a random variable is a function can be confusing (it looks more like a set), but we can always reconstruct the mapping function as the identity function.
\item It is important to understand that we can easily have different random variables from a same sample space.
\item Example: we roll a die two times, $X(e)$ is the sum of the resulting two rolls and $Y(e)$ is the product of these two numbers.
\item For the event $e=\{4,5\}$, $X(e)=9$ and $Y(e)=20$.
\end{itemize}
}
\end{frame}
\begin{frame}{Example}
\begin{itemize}
\item We flip a fair coin 2 times. Let $X$ be the number of heads obtained.
\item The random variable and its distribution is summarized as:
\end{itemize}
\begin{table}
\begin{tabular}{c c|c}
\hline
$e$ & $\mathbb{P}(e)$ & $X(e)$ \\
\hline
TT & 1/4 & 0 \\
TH & 1/4 & 1 \\
HT & 1/4 & 1 \\
HH & 1/4 & 2 \\
\hline
\end{tabular}
\end{table}
\begin{table}
\begin{tabular}{c|c}
\hline
$x$ & $\mathbb{P}(X = x)$ \\
\hline
0 & 1/4 \\
1 & 1/2 \\
2 & 1/4 \\
\hline
\end{tabular}
\end{table}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{itemize}
\item Let $X$ be a R.V , we define \textbf{cumulative distribution function} (CDF) or $F_{X}: \mathbb{R} \rightarrow [0,1]$ as:
\begin{displaymath}
F_{X}(x)=\mathbb{P}(X\leq x)
\end{displaymath}
\item For the previous example of flipping a fair coin twice and counting the number of heads, the CDF is as follows:
\[
F_X(x) =
\begin{cases}
0 & x<0 \\
1/4 & 0 \leq x < 1 \\
3/4 & 1 \leq x < 2 \\
1 & x \geq 2.
\end{cases}
\]
\end{itemize}
}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{figure}[h!]
\centering
\includegraphics[scale=0.4]{pics/cdf_coin.png}
\end{figure}
\begin{itemize}
\item CDF's can be very confusing.
\item Notice that the function is right continuous, non-decreasing, and that it is defined for all x, even though the random variable only takes values 0,1, and 2.
\item Notation: when $X$ is a random variable; $x$ denotes a particular value of the random variable.
\end{itemize}
}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{block}{Discrete Random Variables}
\begin{itemize}
\item A R.V $X$ is \textbf{discrete} if it maps the outputs to a countable set.
\item We define the \textbf{probability function} or \textbf{probability mass function} PMF of a discrete R.V $X$ as $f_{X}(x)=\mathbb{P}(X=x)$.
\item Then $f_{X}(x) \geq 0$ $\forall x \in \mathbb{R}$, and $\sum_{i}f_{X}(x_{i})=1$
\item The CDF of $X$ is related to $f_{X}$ as follows:
\begin{displaymath}
F_{X}= \mathbb{P}(X\leq x)= \sum_{x_{i} \leq x} f_{X}(x_{i})
\end{displaymath}
\end{itemize}
\end{block}
The PMF for the previous example is:
\[
f_X(x) =
\begin{cases}
1/4 & x=0 \\
1/2 & x=1 \\
1/4 & x=2 \\
0 & \text{otherwise.}
\end{cases}
\]
}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{block}{Continuous Random Variable}
\begin{itemize}
\item A R.V $X$ is continuous if:
\item there exists a function $f_{X}$ such that $f_{X}(x) \geq 0$ $\forall x$, $\int_{-\infty}^{\infty}f_{X}(x)dX=1$
\begin{displaymath}
\int_{-\infty}^{\infty}f_{X}(x)dX=1
\end{displaymath}
\item For all $a \geq b$:
\begin{displaymath}
\mathbb{P}(a < X < b) = \int_{a}^{b} f_{X}(x)dx
\end{displaymath}
\end{itemize}
\end{block}
\begin{itemize}
\item The function $f_{X}$ is called the probability density function (PDF).
\item The PDF is related to the CDF as follows:
\begin{displaymath}
F_{X}(x)=\int_{-\infty}^{x}f_{X}(t)dt
\end{displaymath}
\item Then $f_{X}(x) = F'_X(x)$ at all points $x$ where $F_{X}$ is differentiable.
\end{itemize}
}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{itemize}
\item Example: Suppose that $X$ has PDF
\[
f_X(x) =
\begin{cases}
1 & \text{for }0\leq x \leq 1 \\
0 & \text{otherwise.}
\end{cases}
\]
\item Clearly, $f_X(x) \geq 0$ and $\int f_X(x) = 1$.
\item A random variable with this density is said to have a Uniform (0,1) distribution.
\item This is meant to capture the idea of choosing a point at random between 0 and 1.
\item The CDF is given by
\[
F_X(x) =
\begin{cases}
0 & x<0 \\
x & 0\leq x \leq 1 \\
1 & x>1.
\end{cases}
\]
\begin{figure}[h!]
\centering
\includegraphics[scale=0.4]{pics/cdf_uniform.png}
\end{figure}
\end{itemize}
}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{itemize}
\item Continuous random variables can lead to confusion.
\item First, note that if $X$ is continuous then $\mathbb{P}(X = x) = 0$ for every $x$.
\item Don't try to think of $f(x)$ as $\mathbb{P}(X = x)$.
\item This only holds for discrete random variables.
\item We get probabilities from a PDF by integrating.
\end{itemize}
}
\end{frame}
\begin{frame}{R.V Definitions}
\scriptsize{
\begin{itemize}
\item A PDF can be bigger than 1 (unlike a mass function).
\item For example, if $f(x) = 5$ for $x \in [0,1/5]$ and $0$ otherwise.
\item Then $f(x) \geq 0$ and $\int f(x)dx = 1$, so this is a well-defined PDF even though $f(x) = 5$ in some places.
\item A PDF can also be interpreted as the rate of change in the CDF.
\item So where cumulative probability is increasing rapidly, density can easily exceed 1.
\item But if we calculate the area under the density function, it will never exceed 1.
\end{itemize}
}
\end{frame}
\begin{frame}{R.V Definitions}
\begin{figure}[h!]
\centering
\includegraphics[scale=1.1]{pics/pdfcdf.png}
\caption{Source: \url{http://reliawiki.org/index.php/Basic_Statistical_Background}}
\end{figure}
\end{frame}
\begin{frame}{Some Properties}
\begin{enumerate}
\item $ \mathbb{P}( x < X \leq y) = F(y) - F(x)$
\item $ \mathbb{P}(X > x) = 1 - F(x)$
\item If $X$ is continuous:
\begin{eqnarray*}
F(b) - F(a) = \mathbb{P}(a < X < b) = \mathbb{P} ( a \leq X < b) \\
= \mathbb{P} ( a < X \leq b) = \mathbb{P} ( a \leq X \leq b)
\end{eqnarray*}
\end{enumerate}
\end{frame}
\begin{frame}{Quantiles}
\scriptsize{
\begin{itemize}
\item Let $X$ be a R.V with CDF $F$. The inverse CDF or quantile function is defined as \begin{displaymath}
F^{-1}(q)= inf \left\{ x: \ F(x) > q \right\}
\end{displaymath}
\item For $q \in [0,1]$ if $F$ is strictly increasing and continuous, $F^{-1}(q)$ is the only real value such that $F(x)=q$.
\item Then $F^{-1}(1/4)$ is the first quartile, $F^{-1}(1/2)$ the median (or second quartile) and $F^{-1}(3/4)$ the third quartile.
\end{itemize}
}
\end{frame}
\begin{frame}{Quantiles}
\scriptsize{
\begin{figure}[h!]
\centering
\includegraphics[scale=.35]{pics/Probit_plot.png}
\caption{The quantile function of the Normal distribution (probit)\footnote{ \url{https://en.wikipedia.org/wiki/Quantile_function}}}
\end{figure}
}
\end{frame}
\begin{frame}{Some distributions}
\scriptsize{
\begin{table}
\centering
\begin{tabular}{c|c|c}
\hline
& Probability Function & Parameters \\
\hline
Binomial & $f_x= {n \choose x}p^{x}(1-p)^{n-x} $ & $n,p$ \\ \hline
Normal & $f_x=\frac{1}{\sqrt{2\pi}\sigma}\exp^{-\frac{1}{2}\frac{(x-\mu)^2}{\sigma^{2}}}$ & $\mu, \sigma$ \\ \hline
Poisson & $f_x=\frac{1}{x!}\lambda^{x}\exp^{-\lambda}$ & $\lambda$ \\ \hline
Exponential & $f_x= \lambda \exp^{-\lambda x}$ & $\lambda$ \\ \hline
Gamma & $f_x= \frac{\lambda^{\alpha}}{\Gamma(\alpha)} x^{\alpha -1}\exp^{-\lambda x} $ & $\lambda , \alpha$ \\ \hline
Chi-square & $f_x=\frac{1}{2^{k/2} \Gamma(k/2)} x^{(\frac{k}{2} -1)} \exp^{-x/2} $ & $k$ \\
\hline
\end{tabular}
\end{table}
\begin{block}{Warning}
We defined random variables to be mappings from a sample space $\Omega$ to $\mathbb{R}$ but we did not mention the sample space in any of the distributions above. The sample space often becomes implicit but it is really there in the background.
\end{block}
}
\end{frame}
\begin{frame}[fragile]{Binomial Distribution}
\scriptsize{
\begin{itemize}
\item The binomial distribution is a discrete distribution that provides a way to compute the probability of some number of successes out of a number of trials.
\item In each trial there is either success or failure and nothing in between (known as “Bernoulli trials”) given some known probability of success on each trial.
\item Let $n$ be the number of trials, $x$ the number of successes, and $p$ the probability of a success, the probability mass function of the Binomial distribution is as follows:
\begin{displaymath}
f_x(n,p)= {n \choose x}p^{x}(1-p)^{n-x}
\end{displaymath}
\item The binomial coefficient ${n \choose x}$ describes the number of different ways that one can choose $x$ items out of $n$ total items.
\end{itemize}}
\end{frame}
\begin{frame}[fragile]{Binomial Distribution}
\scriptsize{
\begin{itemize}
\item Example: on Jan 20 2018, the basketball player Steph Curry hit only 2 out of 4 free throws in a game against the Houston Rockets.
\item We know that Curry's overall probability of hitting free throws across the entire season was 0.91.
\item What is probability that he would hit only 50\% of his free throws in a game?
\begin{displaymath}
f_2(4,0.91) = {4 \choose 2}0.91^{2}(1-0.91)^{4-2}=0.040
\end{displaymath}
In R:
\begin{verbatim}
> choose(4,2)*0.91^2*(1-0.91)^2
[1] 0.04024566
> # more compactly
> dbinom(x=2,size=4,p=0.91)
[1] 0.04024566
\end{verbatim}
\end{itemize}}
\end{frame}
\begin{frame}{The Normal Distribution}
\scriptsize{
\begin{itemize}
\item The normal or Gaussian distribution is extremely important in statistics, in part because it shows up all the time in nature.
\item It is controlled by two parameters, a mean $\mu$ and a standard deviation $\sigma$.
\begin{figure}[h!]
\centering
\includegraphics[scale=0.13]{pics/gaussian.jpg}
\end{figure}
\item As we will see in the following example~\cite{mcelreath2020statistical}, the normal distribution is observed whenever many small, independent variations are summed together to produce a value.
\end{itemize}}
\footnotemark{Figure source: \url{http://sfonline.barnard.edu/wp-content/uploads/2015/12/gaussian-distribution.jpg}}
\end{frame}
\begin{frame}{Normal Distribution}
\scriptsize{
\begin{itemize}
\item Suppose you and a thousand of your closest friends line up on the halfway line of a soccer field (football pitch).
\item Each of you has a coin in your hand. At the sound of the whistle, you begin flipping the coins.
\item Each time a coin comes up heads, that person moves one step
towards the left-hand goal.
\item Each time a coin comes up tails, that person moves one step towards the right-hand goal.
\item Each person flips the coin 16 times, follows the implied moves,
and then stands still.
\item Now we measure the distance of each person from the halfway line.
\item Can you predict what proportion of the thousand people who are standing on the halfway line? How about the proportion 5 yards left of the line?
\end{itemize}}
\end{frame}
\begin{frame}{Normal Distribution}
\scriptsize{
\begin{itemize}
\item It’s hard to say where any individual person will end up, but you can say with great confidence what the collection of positions will be.
\item The distances will be distributed in approximately normal, or Gaussian, fashion.
\item This is true even though the underlying distribution is binomial.
\item It does this because there are so many more possible ways to realize a sequence of left-right steps that sums to zero.
\item There are slightly fewer ways to realize a sequence that ends
up one step left or right of zero, and so on, with the number of possible sequences declining in the characteristic bell curve of the normal distribution.
\end{itemize}}
\end{frame}
\begin{frame}{Soccer 1}
\begin{figure}[h!]
\centering
\includegraphics[scale=0.3]{pics/soccer1.png}
\caption{Source: \url{https://github.com/rmcelreath/stat_rethinking_2020}}
\end{figure}
\end{frame}