The Law f Ttal Prbability, Bayes Rule, and Randm Variables (Oh My!)
Administrivia Hmewrk 2 is psted and is due tw Friday s frm nw If yu didn t start early last time, please d s this time. Gd Milestnes: Finish Prblems 1-3 this week. Mre math, sme prgramming. Finish Prblems 4-5 next week. Less math, mre prgramming.
Administrivia Reminder f the curse Cllabratin Plicy: Inspiratin is Free: yu may discuss hmewrk assignments with anyne. Yu are especially encuraged t discuss slutins with yur instructr and yur classmates. Plagiarism is Frbidden: the assignments and cde that yu turn in shuld be written entirely n yur wn. D NOT Search fr a Slutin On-Line: Yu may nt actively search fr a slutin t the prblem frm the internet. This includes psting t surces like StackExchange, Reddit, Chegg, etc Vilatin f ANY f the abve will result in an F in the curse / trip t Hnr Cuncil
Previusly n CSCI 3022 Cnditinal Prbability: The prbability that A ccurs given that C ccurred P (A C) P (A C) P (C) Multiplicatin Rule: P (A C) P (A C) P (C) Independence: Events A and B are independent if 1. 2. P (A B) P (A) P (B A) P (B) 3. P (A B) P (A)P (B)
Law f Ttal Prbability Example: Suppse I have tw bags f marbles. The first bag cntains 6 white marbles and 4 black marbles. The secnd bag cntains 3 white marbles and 7 black marbles. Nw suppse I put the tw bags in a bx. If I clse my eyes, grab a bag frm the bx, and then grab a marble frm the bag, what is the prbability that it is black? H BLACK 20 0 0.55. t + ± E + E- ' t
Law f Ttal Prbability Example: Same scenari as befre, but nw suppse that the first bag is much larger than the secnd bag, s that when I reach int the bx I m twice as likely t grab the first bag as the secnd. What is the prbability f grabbing a black marble? P ( B.) % P(Bz) 1/3 25. t + I. E 8%+30. T. ±
Law f Ttal Prbability Def: Suppse C 1,C 2,...,C m are disjint events such that C 1 C 2 C m. The prbability f an arbitrary event A can be expressed as: P (A) P (A C 1 )P (C 1 )+P(A C 2 )P (C 2 )+ + P (A C m )P (C m ) E I n YFE #
Let s Flip Things Arund PCB, )PlB) Example: Suppse I have tw bags f marbles. The first bag cntains 6 white marbles and 4 black marbles. The secnd bag cntains 3 white marbles and 7 black marbles. Nw suppse I put the tw bags in a bx. If I clse my eyes, grab a bag frm the bx, reach int the bag and pull ut a white marble. What is the prbability that I picked Bag 1? cmplete PCB, )P( Bil - tz PCB, ( WHITE ) PCB.tk ) PC WHITE ) PIWHHEIB,) PIWHITEIBD 340 PCB, NWHITE ) PC WHITE IBDPCB, )
Let s Flip Things Arund Example: Suppse I have tw bags f marbles. The first bag cntains 6 white marbles and 4 black marbles. The secnd bag cntains 3 white marbles and 7 black marbles. Nw suppse I put the tw bags in a bx. If I clse my eyes, grab a bag frm the bx, reach int the bag and pull ut a white marble. What is the prbability that I picked Bag 1? Hw culd we cmpute this? PCB, 1 WHITE ) - PCWHITEIBDPIBDPCWHITE ) PC WHITE 1 B. ) DPIB, % Yz white IBDPCB, ) + PIWHHI 1132 )MB2 ) g.tt?. Esque % - PD }
Let s Flip Things Arund Example: Suppse I have tw bags f marbles. The first bag cntains 6 white marbles and 4 black marbles. The secnd bag cntains 3 white marbles and 7 black marbles. Nw suppse I put the tw bags in a bx. If I clse my eyes, grab a bag frm the bx, reach int the bag and pull ut a white marble. What is the prbability that I picked Bag 1? Hw culd we cmpute this? Let s write dwn literally everything we knw
Let s Flip Things Arund Example: Suppse I have tw bags f marbles. The first bag cntains 6 white marbles and 4 black marbles. The secnd bag cntains 3 white marbles and 7 black marbles. Nw suppse I put the tw bags in a bx. If I clse my eyes, grab a bag frm the bx, reach int the bag and pull ut a white marble. What is the prbability that I picked Bag 1? Hw culd we cmpute this? Let s write dwn literally everything we knw
Let s Flip Things Arund Example: Suppse I have tw bags f marbles. The first bag cntains 6 white marbles and 4 black marbles. The secnd bag cntains 3 white marbles and 7 black marbles. Nw suppse I put the tw bags in a bx. If I clse my eyes, grab a bag frm the bx, reach int the bag and pull ut a white marble. What is the prbability that I picked Bag 1? Hw culd we cmpute this? Let s write dwn literally everything we knw
Bayes Rule The ntin f using evidence (the marble is White) t update ur belief abut an event (that we selected Bx 1 frm the bx) is the crnerstne f a statistical framewrk called Bayesian Reasning. The frmulas we derived in the previus example are called Bayes Rule r Bayes Therem P (A C) t f P (C A)P (A) P (C) y PROB LIKELIHOOD a- PRIOR P (C A)P (A) P (C A)P (A)+P (C A c )P (A c ) OF EVIDENCE
Bayes Rule The ntin f using evidence (the marble is White) t update ur belief abut an event (that we selected Bx 1 frm the bx) is the crnerstne f a statistical framewrk called Bayesian Reasning. The frmulas we derived in the previus example are called Bayes Rule r Bayes Therem P (A C) P (C A)P (A) P (C) P (C A)P (A) P (C A)P (A)+P (C A c )P (A c )
Bayes Rule Bayes Rule has applicatins all ver science. Shuld we test men fr prstate cancer? Bayes Rule allws us t write dwn the prbability that smene wh tests psitive fr prstate cancer actually has prstate cancer. False psitives may cause huge amunts f stress, heartache, and pain. On the ther hand, if yu dn t test fr cancer, yu may nt discver it until it s t late Things are slightly mre cmplicated than this: Other factrs are age, PSA cutffs, etc.
Bayes Rule Classic Example: Suppse that 1% f men ver the age f 40 have prstate cancer. Als suppse that a test fr prstate cancer exists with the fllwing prperties: 90% f peple have cancer will test psitive and 8% f peple wh d nt have cancer will als test psitive. What is the prbability that a persn wh tests psitive fr cancer actually has cancer? C Have cancer + ps test - neg test PCC It ) PCt1c)PK). e Pct ) Pct 1C ) Pcc ). 'ftp.tp.ge?py@ 0.07
Bayes Rule Classic Example: Suppse that 1% f men ver the age f 40 have prstate cancer. Als suppse that a test fr prstate cancer exists with the fllwing prperties: 90% f peple have cancer will test psitive and 8% f peple wh d nt have cancer will als test psitive. What is the prbability that a persn wh tests psitive fr cancer actually has cancer?
Bayes Rule Classic Example: Suppse that 1% f men ver the age f 40 have prstate cancer. Als suppse that a test fr prstate cancer exists with the fllwing prperties: 90% f peple have cancer will test psitive and 8% f peple wh d nt have cancer will als test psitive. What is the prbability that a persn wh tests psitive fr cancer actually has cancer? Pct ) PAI c) Pcc ) + Pct Icc ) PKD E t + Is! 8.8%
Randm Variables Suppse that I rll tw dice What is the mst cmbinatin? What is the mst likely sum?
Randm Variables Suppse that I rll tw dice What is the mst cmbinatin? What is the mst likely sum?
Randm Variables What is the sample space? w, 1st pll we 2nd pll 123456-2 -1 a E
Randm Variables What is the sample space? The Key: the dice are randm, s the sum is randm. Let s sidestep the sample space entirely and just g straight t the thing we care abut: the sum. We call the sum f the dice a randm variable.
Randm Variables What is the sample space? The Key: the dice are randm, s the sum is randm. Let s sidestep the sample space entirely and just g straight t the thing we care abut: the sum. We call the sum f the dice a randm variable. Def: a discrete randm variable is a functin that maps the elements f the sample space T a finite number f values a 1,a 2,...,a n r an infinite number f values a 1,a 2,... Examples: Sum f the dice, difference f the dice, maximum f the dice Number f cin flips until we get a heads
Prbability Mass Functin. Def: a prbability mass functin is the map between the randm variable s values and the prbabilities f thse values f(a) P (X a) 9 RU. Called a prbability mass functin (PMF) because each f the randm variable values has sme prbability mass (r weight) assciated with it Because the PMF is a prbability functin, the sum f all the masses must be what? El, Fla ;) /
PCHKP Prbability Mass Functin Questin: what is the prbability mass functin fr the number f cin flips until a biased cin cmes up heads? R { H, TH, TTH, TTTH,. -. } I 2 3 4 - - - f p ctpp I. ppp ' c ppp - - -
Cumulative Distributin Functin Def: a cumulative distributin functin (CDF) is a functin whse value at a pint a is the cumulative sum f prbability masses up until a. F (a) P (X a) F (6) - prb OF Rlling A sum Questin: What is the relatinship between the PMF and the CDF? I 6 Fca ) Z, Fca ) X a
Cumulative Distributin Functin Questin: what is the prbability that I rll tw dice and they add up t at least 9? PCX - { 9,10,k,z})P( > 9) 1- P( < 9) 1- P(X±8 ) 1- FC8) I
OK! Let s G t Wrk! Get in grups, get ut laptp, and pen the Lecture 6 In-Class Ntebk Let s: Get sme mre practice with the Law f Ttal Prbability and Bayes Rule Lk at a famus Bayesian example called the Mnte Hall Prblem