Top Banner
CS322 Week 11 - Wednesday
31

CS322

Jan 02, 2016

Download

Documents

Luke Schwartz

Week 11 - Wednesday. CS322. Last time. What did we talk about last time? Exam 2 post-mortem Combinations. Questions?. Logical warmup. This is a puzzle we should have done with sequences Consider the following sequence, which should be read from left to right, starting at the top row 1 - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS322

CS322Week 11 - Wednesday

Page 2: CS322

Last time

What did we talk about last time? Exam 2 post-mortem Combinations

Page 3: CS322

Questions?

Page 4: CS322

Logical warmup

This is a puzzle we should have done with sequences

Consider the following sequence, which should be read from left to right, starting at the top row

11 12 1

1 2 1 11 1 1 2 2 1

What are the next two rows in the sequence?

Page 5: CS322

Back to Combinations

Page 6: CS322

Combinations example

How many ways are there to choose 5 people out of a group of 12?

What if two people don't get along? How many 5 person teams can you make from a group of 12 if those two people cannot both be on the team?

Page 7: CS322

Poker examples

How many five-card poker hands contain two pairs?

If a five-card hand is dealt at random from an ordinary deck of cards, what is the probability that the hand contains two pairs?

Page 8: CS322

r-combinations with repetitions

What if you want to take r things out of a set of n things, but you are allowed to have repetitions?

Think of it as putting r things in n categories

Example: n = 5, r = 4

We could represent this as x||xx|x| That's an r x's and n – 1 |'s

1 2 3 4 5

x xx x

Page 9: CS322

r-combinations with repetitions

So, we can think of taking an r-combination with repetitions as choosing r items in a string that is r + n – 1 long and marking those as x's

Consequently, the number of r-combinations with repetitions is

r

nr 1

Page 10: CS322

Example

Let's say you grab a handful of 10 Starbursts

Original Starbursts come in Cherry Lemon Strawberry Orange

How many different handfuls are possible?

How many possible handfuls will contain at least 3 cherry?

Page 11: CS322

Handy dandy guide to counting

This is a quick reminder of all the different ways you can count things:

Order Matters Order Doesn't Matter

Repetition Allowed nk

Repetition Not Allowed P(n,k)

k

nk 1

k

n

Page 12: CS322

Bionomial Theorem and Pascal's TriangleStudent Lecture

Page 13: CS322

Binomial Matters

Page 14: CS322

Pascal's Triangle

Hopefully, you are all familiar with Pascal's Triangle, the beginning of which is:

If we number rows and columns starting at 0, note that the value of row n, column r is exactly

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

r

n

Page 15: CS322

Pascal's Formula

Pascal's Triangle works because of Pascal's Formula:

We can easily show its truth:

r

n

r

n

r

n

1

1

)!1(!)!1(

)!1(!)1(!

)!1(!)1(!

)!1(!!

)!(!!

)!1()!1(!

1

rnrn

rnrnn

rnrrnn

rnrrn

rnrn

rnrn

r

n

r

n

Page 16: CS322

Binomial Theorem

a + b is called a binomial Using combinations (or Pascal's

Triangle) it is easy to compute (a + b)n

We could prove this by induction, but you probably don't care

kknn

k

n bak

nba

0

)(

Page 17: CS322

Binomial Example

Compute (1 – x)6 using the binomial theorem

Page 18: CS322

More on Probability

Page 19: CS322

Probability axioms

Let A and B be events in the sample space S 0 ≤ P(A) ≤ 1 P() = 0 and P(S) = 1 If A B = , then P(A B) = P(A) + P(B) It is clear then that P(Ac) = 1 – P(A) More generally, P(A B) = P(A) + P(B) – P(A B)

All of these axioms can be derived from set theory and the definition of probability

Page 20: CS322

Union probability example

What is the probability that a card drawn randomly from an Anglo-American 52 card deck is a face card (jack, queen, or king) or is red (hearts or diamonds)?

Hint: Compute the probability that it is a face

card Compute the probability that it is red Compute the probability that it is both

Page 21: CS322

Expected value

Expected value is one of the most important concepts in probability, especially if you want to gamble

The expected value is simply the sum of all events, weighted by their probabilities

If you have n outcomes with real number values a1, a2, a3, … an, each of which has probability p1, p2, p3, … pn, then the expected value is:

n

kkkpa

1

Page 22: CS322

Expected value: Roulette

A normal American roulette wheel has 38 numbers: 1 through 36, 0, and 00

18 numbers are red, 18 numbers are black, and 0 and 00 are green

The best strategy you can have is always betting on black (or red)

If you bet $1 on black and win, you get $1, but you lose your dollar if it lands red or green

What is the expected value of a bet?

Page 23: CS322

Conditional probability

Given that some event A has happened, the probability that some event B will happen is called conditional probability

This probability is:

)()(

)|(APBAP

ABP

Page 24: CS322

Conditional probability example

Given two, fair, 6-sided dice, what is the probability that the sum of the numbers they show when rolled is 8, given that both of the numbers are even?

Page 25: CS322

Bayes' Theorem

Let sample space S be a union of mutually disjoint events B1, B2, B3, … Bn

Let A be an event in S Let A and B1 through Bn have non-

zero probabilities For Bk where 1 ≤ k ≤ n

)()|(...)()|()()|()()|(

)|(2211 nn

kkk BPBAPBPBAPBPBAP

BPBAPABP

Page 26: CS322

Applying Bayes' theorem

Bayes' theorem is often used to evaluate tests that can have false positives and false negatives

Consider a test for a disease that 1 in 5000 people have The false positive rate is 3% The false negative rate is 1%

What's the probability that a person who tests positive for the disease has the disease?

Let A be the event that the person tests positively for the disease

Let B1 be the event that the person actually has the disease

Let B2 be the event that the person does not have the disease

Apply Bayes' theorem

Page 27: CS322

Independent events

If events A and B are events in a sample space S , then these events are independent if and only ifP(A B) = P(A)∙P(B)

This should be clear from conditional probability

If A and B are independent, then P(B|A) = P(B)

)()()()(

)()()|(

BAPBPAPAPBAP

BPABP

Page 28: CS322

Quiz

Page 29: CS322

Upcoming

Page 30: CS322

Next time…

Finish probability Graph basics

Page 31: CS322

Reminders

Work on Homework 8 Due Friday

Start reading Chapter 10