SlideShare a Scribd company logo
1 of 20
Download to read offline
Stat310
Conditional probability


    Hadley Wickham
Housekeeping
How many of you have a cellphone?
How many of you now have the textbook?
Office hours: after class, tomorrow 4-5pm
(location: TBA)
Mailing list: http://groups.google.com/group/
stat310
Class party earnings update
Events vs. outcomes
Events vs. outcomes
S = {a, b, c}.
A = {a, b}. B = {b, c}, C = {c}
Set of all events = {{a, b, c}, {a, b}, {a, c},
{b, c}, {a}, {b}, {c}, ∅}
S = {o1, o2, o3, ...}
A = {o1, o2} B = {o2, o4, ...} C = {o154}
Set of all events = ?
Event is a subset. Outcome is an element.
Motivation
Imagine you select a person at random and give
them an HIV test. If the HIV test is positive what’s
the probability that they have HIV?
a) 95-100%
b) 90-94%
c) 80-89%
d) 65-79%
e) < 64%
It’s 50%!
1. Probability paradox
2. Conditional probability
3. Law of total probability
4. Independence
Your turn


A family has two children. One of the
children is a boy. What is the probability
that the other is a girl?
Your turn


A family has two children. They do not
have two girls. What is the probability
they have a boy and a girl?
What is a paradox?
A paradox is a statement or group of
statements that leads to a contradiction
or a situation which defies intuition.
(http://en.wikipedia.org/wiki/Paradox)

Our statistical intuition is often wrong,
so we need a careful mathematical
process to check
Process

1. Write out complete sample space
2. Remove excluded events
3. Define event of interest
4. Calculate probability
Conditional probability

Definition. Sample space interpretation.
Is the conditional probability a probability
function?
Multiplication “rule”
Example

             What is the probability that a randomly
             picked person out of this class is
             pregnant in a years time?
             (~1.7 million pregnancies to girls aged
             20-24, ~30 million girls)



http://www.cdc.gov/mmwr/preview/mmwrhtml/ss5806a1.htm?s_cid=ss5806a1_e#tab29
Steps
1. Define basic events.
2. Write problem as probability of
conditional event.
3. Think about the easiest way to
calculate that probability (complements?
intersection? conditioning?)
Law of total
probability
Example

Randomly pick a guy from this class.
What is the probability he gets a girl
pregnant in the next year?
How might we want to partition the
sample space?
Data
             P(no sex) = 0.2
             P(gay sex) = 0.05
             P(no contraception) = 0.18
             P(uses condom) = 0.71
             P(withdrawal) = 0.11
             P(pregnant | no contraception) = 0.85
             P(pregnant | use condom) = 0.15
             P(pregnant | withdrawal) = 0.27


http://www.cdc.gov/mmwr/preview/mmwrhtml/ss5806a1.htm?s_cid=ss5806a1_e#tab29
Independence
If A and B are independent, then
P(A | B) = P(A) and P(B | A) = P(B).
In words: The fact that B occurred does
not give us any information about A (and
vice versa)
This implies P(A ∩ B) = P(A) P(B). (Why?)
Mutually independent if ...
Your turn

Are mutually exclusive events
independent? Why/why not?
Toss three fair coins. Consider the events
A = {all heads or all tails}, B = {at least
two heads}, C = {at most two tails}. Which
pairs of events are independent?

More Related Content

Viewers also liked

Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2Chris Rucker
 
Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)Hadley Wickham
 
R workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 seriesR workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 seriesVivian S. Zhang
 
Machine learning in R
Machine learning in RMachine learning in R
Machine learning in Rapolol92
 
4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply Function4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply FunctionSakthi Dasans
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyrRomain Francois
 
Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)Ram Narasimhan
 
Introducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with rIntroducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with rVivian S. Zhang
 
Grouping & Summarizing Data in R
Grouping & Summarizing Data in RGrouping & Summarizing Data in R
Grouping & Summarizing Data in RJeffrey Breen
 

Viewers also liked (20)

16 Sequences
16 Sequences16 Sequences
16 Sequences
 
24 modelling
24 modelling24 modelling
24 modelling
 
20 date-times
20 date-times20 date-times
20 date-times
 
21 spam
21 spam21 spam
21 spam
 
Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2
 
Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)
 
Graphical inference
Graphical inferenceGraphical inference
Graphical inference
 
R workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 seriesR workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 series
 
03 Modelling
03 Modelling03 Modelling
03 Modelling
 
23 data-structures
23 data-structures23 data-structures
23 data-structures
 
R packages
R packagesR packages
R packages
 
02 Ddply
02 Ddply02 Ddply
02 Ddply
 
01 Intro
01 Intro01 Intro
01 Intro
 
Reshaping Data in R
Reshaping Data in RReshaping Data in R
Reshaping Data in R
 
Machine learning in R
Machine learning in RMachine learning in R
Machine learning in R
 
4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply Function4 R Tutorial DPLYR Apply Function
4 R Tutorial DPLYR Apply Function
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyr
 
Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)
 
Introducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with rIntroducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with r
 
Grouping & Summarizing Data in R
Grouping & Summarizing Data in RGrouping & Summarizing Data in R
Grouping & Summarizing Data in R
 

Similar to 03 Conditional

Complements and Conditional Probability, and Bayes' Theorem
 Complements and Conditional Probability, and Bayes' Theorem Complements and Conditional Probability, and Bayes' Theorem
Complements and Conditional Probability, and Bayes' TheoremLong Beach City College
 
Complements conditional probability bayes theorem
Complements  conditional probability bayes theorem  Complements  conditional probability bayes theorem
Complements conditional probability bayes theorem Long Beach City College
 
Introduction to probability
Introduction to probabilityIntroduction to probability
Introduction to probabilityGlobal Polis
 
1 Probability Please read sections 3.1 – 3.3 in your .docx
 1 Probability   Please read sections 3.1 – 3.3 in your .docx 1 Probability   Please read sections 3.1 – 3.3 in your .docx
1 Probability Please read sections 3.1 – 3.3 in your .docxaryan532920
 
BASIC CONCEPT OF PROBABILITY by Elem Stppt
BASIC CONCEPT OF PROBABILITY by Elem StpptBASIC CONCEPT OF PROBABILITY by Elem Stppt
BASIC CONCEPT OF PROBABILITY by Elem StpptJAMESFRANCISGOSE
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data AnalyticsSSaudia
 
Statistik Chapter 5
Statistik Chapter 5Statistik Chapter 5
Statistik Chapter 5WanBK Leo
 
vann dia and probability.pptx
vann dia and probability.pptxvann dia and probability.pptx
vann dia and probability.pptxMrMuhammadAsif1
 
Probability theory good
Probability theory goodProbability theory good
Probability theory goodZahida Pervaiz
 
Basic Concept Of Probability
Basic Concept Of ProbabilityBasic Concept Of Probability
Basic Concept Of Probabilityguest45a926
 

Similar to 03 Conditional (20)

Complements and Conditional Probability, and Bayes' Theorem
 Complements and Conditional Probability, and Bayes' Theorem Complements and Conditional Probability, and Bayes' Theorem
Complements and Conditional Probability, and Bayes' Theorem
 
Complements conditional probability bayes theorem
Complements  conditional probability bayes theorem  Complements  conditional probability bayes theorem
Complements conditional probability bayes theorem
 
Basic concepts of probability
Basic concepts of probability Basic concepts of probability
Basic concepts of probability
 
Basic concepts of probability
Basic concepts of probabilityBasic concepts of probability
Basic concepts of probability
 
tps5e_Ch5_3.ppt
tps5e_Ch5_3.ppttps5e_Ch5_3.ppt
tps5e_Ch5_3.ppt
 
tps5e_Ch5_3.ppt
tps5e_Ch5_3.ppttps5e_Ch5_3.ppt
tps5e_Ch5_3.ppt
 
Day 3.pptx
Day 3.pptxDay 3.pptx
Day 3.pptx
 
Introduction to probability
Introduction to probabilityIntroduction to probability
Introduction to probability
 
1 Probability Please read sections 3.1 – 3.3 in your .docx
 1 Probability   Please read sections 3.1 – 3.3 in your .docx 1 Probability   Please read sections 3.1 – 3.3 in your .docx
1 Probability Please read sections 3.1 – 3.3 in your .docx
 
Probabilty1.pptx
Probabilty1.pptxProbabilty1.pptx
Probabilty1.pptx
 
Addition rule and multiplication rule
Addition rule and multiplication rule  Addition rule and multiplication rule
Addition rule and multiplication rule
 
BASIC CONCEPT OF PROBABILITY by Elem Stppt
BASIC CONCEPT OF PROBABILITY by Elem StpptBASIC CONCEPT OF PROBABILITY by Elem Stppt
BASIC CONCEPT OF PROBABILITY by Elem Stppt
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data Analytics
 
Basic Concepts of Probability
Basic Concepts of ProbabilityBasic Concepts of Probability
Basic Concepts of Probability
 
03 Probability.pdf
03 Probability.pdf03 Probability.pdf
03 Probability.pdf
 
Probability.pptx
Probability.pptxProbability.pptx
Probability.pptx
 
Statistik Chapter 5
Statistik Chapter 5Statistik Chapter 5
Statistik Chapter 5
 
vann dia and probability.pptx
vann dia and probability.pptxvann dia and probability.pptx
vann dia and probability.pptx
 
Probability theory good
Probability theory goodProbability theory good
Probability theory good
 
Basic Concept Of Probability
Basic Concept Of ProbabilityBasic Concept Of Probability
Basic Concept Of Probability
 

More from Hadley Wickham (20)

27 development
27 development27 development
27 development
 
27 development
27 development27 development
27 development
 
22 spam
22 spam22 spam
22 spam
 
19 tables
19 tables19 tables
19 tables
 
18 cleaning
18 cleaning18 cleaning
18 cleaning
 
17 polishing
17 polishing17 polishing
17 polishing
 
16 critique
16 critique16 critique
16 critique
 
15 time-space
15 time-space15 time-space
15 time-space
 
14 case-study
14 case-study14 case-study
14 case-study
 
13 case-study
13 case-study13 case-study
13 case-study
 
12 adv-manip
12 adv-manip12 adv-manip
12 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
10 simulation
10 simulation10 simulation
10 simulation
 
10 simulation
10 simulation10 simulation
10 simulation
 
09 bootstrapping
09 bootstrapping09 bootstrapping
09 bootstrapping
 
08 functions
08 functions08 functions
08 functions
 
07 problem-solving
07 problem-solving07 problem-solving
07 problem-solving
 
06 data
06 data06 data
06 data
 
05 subsetting
05 subsetting05 subsetting
05 subsetting
 

03 Conditional

  • 2. Housekeeping How many of you have a cellphone? How many of you now have the textbook? Office hours: after class, tomorrow 4-5pm (location: TBA) Mailing list: http://groups.google.com/group/ stat310 Class party earnings update Events vs. outcomes
  • 3.
  • 4.
  • 5. Events vs. outcomes S = {a, b, c}. A = {a, b}. B = {b, c}, C = {c} Set of all events = {{a, b, c}, {a, b}, {a, c}, {b, c}, {a}, {b}, {c}, ∅} S = {o1, o2, o3, ...} A = {o1, o2} B = {o2, o4, ...} C = {o154} Set of all events = ? Event is a subset. Outcome is an element.
  • 6. Motivation Imagine you select a person at random and give them an HIV test. If the HIV test is positive what’s the probability that they have HIV? a) 95-100% b) 90-94% c) 80-89% d) 65-79% e) < 64%
  • 8. 1. Probability paradox 2. Conditional probability 3. Law of total probability 4. Independence
  • 9. Your turn A family has two children. One of the children is a boy. What is the probability that the other is a girl?
  • 10. Your turn A family has two children. They do not have two girls. What is the probability they have a boy and a girl?
  • 11. What is a paradox? A paradox is a statement or group of statements that leads to a contradiction or a situation which defies intuition. (http://en.wikipedia.org/wiki/Paradox) Our statistical intuition is often wrong, so we need a careful mathematical process to check
  • 12. Process 1. Write out complete sample space 2. Remove excluded events 3. Define event of interest 4. Calculate probability
  • 13. Conditional probability Definition. Sample space interpretation. Is the conditional probability a probability function? Multiplication “rule”
  • 14. Example What is the probability that a randomly picked person out of this class is pregnant in a years time? (~1.7 million pregnancies to girls aged 20-24, ~30 million girls) http://www.cdc.gov/mmwr/preview/mmwrhtml/ss5806a1.htm?s_cid=ss5806a1_e#tab29
  • 15. Steps 1. Define basic events. 2. Write problem as probability of conditional event. 3. Think about the easiest way to calculate that probability (complements? intersection? conditioning?)
  • 17. Example Randomly pick a guy from this class. What is the probability he gets a girl pregnant in the next year? How might we want to partition the sample space?
  • 18. Data P(no sex) = 0.2 P(gay sex) = 0.05 P(no contraception) = 0.18 P(uses condom) = 0.71 P(withdrawal) = 0.11 P(pregnant | no contraception) = 0.85 P(pregnant | use condom) = 0.15 P(pregnant | withdrawal) = 0.27 http://www.cdc.gov/mmwr/preview/mmwrhtml/ss5806a1.htm?s_cid=ss5806a1_e#tab29
  • 19. Independence If A and B are independent, then P(A | B) = P(A) and P(B | A) = P(B). In words: The fact that B occurred does not give us any information about A (and vice versa) This implies P(A ∩ B) = P(A) P(B). (Why?) Mutually independent if ...
  • 20. Your turn Are mutually exclusive events independent? Why/why not? Toss three fair coins. Consider the events A = {all heads or all tails}, B = {at least two heads}, C = {at most two tails}. Which pairs of events are independent?