220 likes | 396 Views
Probability for Computer Scientists. CS109. Cynthia Lee. Today’s Topics. Last time: Combinations Permutations TODAY: Probability! Sample Spaces and Set Theory Axioms of Probability Next week: Conditional Probability Independence Discrete Random Variables. Society of Black
E N D
Probability for Computer Scientists CS109 Cynthia Lee
Today’s Topics • Last time: • Combinations • Permutations • TODAY: Probability! • Sample Spaces and Set Theory • Axioms of Probability • Next week: • Conditional Probability • Independence • Discrete Random Variables
Society of Black Scientists and Engineers American Indian Science and Engineering Society Looking for a diverse community within engineering and science at Stanford? Join one of Stanford’s engineering diversity societies! Society of Latino Engineers Society of Women Engineers Meetings: Tuesdays 12:00PM at BCSC Meetings: Mondays 12:00PM at NACC Meetings: Fridays 12:00PM at BCSC Meetings: Wednesdays 12:00PM at MERL, Building 660, 2nd floor
Computer Science-specific club: Women in CS http://wics.stanford.edu
Warm-up review of last lecture: Karel Goes 3-D! • Beloved Karel the robot moves around in its 2-D grid. It can only move up/down/left/right (not diagonally), one square at a time. • Imagine Karel goes 3-D and wants to move from one corner at coordinate (0,0,0) to the opposite corner at coordinate (x,y,z), and will only move in a positive direction in any dimension: • How many different sequences of steps are there to get there?
Warm-up review of last lecture: Karel Goes 3-D! • Beloved Karel the robot moves around in its 2-D grid. It can only move up/down/left/right (not diagonally), one square at a time. • Imagine Karel goes 3-D and wants to move from one corner at coordinate (0,0,0) to the opposite corner at coordinate (x,y,z), and will only move in a positive direction in any dimension: • How many different sequences of steps are there to get there? • First decide which tool to use: • Permutations • Combinations • Multinomial • Divider-method multinomial • GIVE ME A HINT, PLS.
Warm-up review of last lecture: Karel Goes 3-D! • HINT: • Must eventually go a steps in x dir • …and b steps in y dir • …and c steps in z dir • The question is, how can we permute the order of these (but ignore duplicates) • Which problem we saw last time most resembles this? • iPhone 4-smudge codes • Choosing 2 Hunger Games tributes • moo/Mississippi • Police officers in precincts
Warm-up review of last lecture: Karel Goes 3-D! • Beloved Karel the robot moves around in its 2-D grid. It can only move up/down/left/right (not diagonally), one square at a time. • Imagine Karel goes 3-D and wants to move from one corner at coordinate (0,0,0) to the opposite corner at coordinate (x,y,z), and will only move in a positive direction in any dimension: • How many different sequences of steps are there to get there? • First decide which tool to use: • Permutations • Combinations • Multinomial • Divider-method multinomial
Warm-up review of last lecture: Karel Goes 3-D! • Imagine Karel goes 3-D and wants to move from one corner at coordinate (0,0,0) to the opposite corner at coordinate (a,b,c), and will only move in a positive direction in any dimension: • How many different sequences of steps are there to get there? • Intuition: • Must eventually go a steps in x dir • …and b steps in y dir • …and c steps in z dir • The question is, how can we permute these (but ignore duplicates) • moo/Mississippi problem is the same! • MULTINOMIAL:
Sample Spaces • Setsthat represent ALL possible outcomes of an experiment • Can be sets of numbers, things, people… • Can be enumerated: • Toss of a coin: • Roll of a dice: • Or specified with set builder notation: • # of emails in a day: • # of hours spent watching YouTube in a day:
Events • Setsthat are subsets of the sample space • The outcome of an experiment • Coin comes up heads: • At least one head on two flips: • Die roll less than 3: • # of emails in a day is less than 20: • Wasted day: • Note about Ross textbook: • For subset that can include the entire set (i.e., not strict subset), Ross uses: • You might be more used to seeing:
Venn Diagrams! • : Hey! That’s unfair that gets a shorthand and doesn’t! You’re right, that’s unfair.
DeMorgan’s Laws ♥ ♥ • What does that mean?
Axioms of Probability • Axiom 3, more generally: • For any mutually exclusive events E1, E2, …
Ok…so what does that mean? Why do we care? • A few of the implications of the Axioms: • Makes it easy to calculate the probability of the complement of an event: • We can compare probabilities of events that are subsets of each other:
Easy (and common) case: Equally likely events in S • Some sample spaces are comprised of outcomes that are all equally likely • We can compare probabilities of events that are subsets of each other: • Coin flip • Die roll • There are special rules for this:
Manufacturing Quality Assurance • You manufacture computer chips • In one day, you manufacture n chips • On a certain day, it happens that 1 of them is defective • You pull out k for testing • What are the chances that you find the defective one in your test? • We’re going to do this the long/thorough way! • We use the “equally likely” rule: • P(defective one is found in k tests) =
What happens in Vegas stays in Vegas …your money also stays in Vegas. • Consider 5-card poker hands • “straight” is 5 consecutive rank cards of any suit • “straight flush” is give consecutive rank cards of same suit • What is P(straight, but not straight flush)? • |S| = • “Of 52 cards, choose 5 of them” • What is P(straight, but not straight flush)?