63
Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

AdministrativeSep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 dueSep. 28 8am – problem session

Oct. 2Oct. 4 – QUIZ #2

(pages 45-79 of DPV)

Page 2: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Administrative

You may work with one other person on homeworks, but you must each write up your

solutions separately (without any written aid). If you work with another person, indicate who you worked with on your solution (thus you should each indicate each other).

Homework rules:

All cases of suspected dishonesty must be reported to the Board, either through a shortform resolution or by forwarding a case to the Board for a hearing. Faculty may not come to an understanding with a student on their own in a case of suspected dishonesty, but must use the short form resolution or submit a case.

University Academic Honesty Policy:

Page 3: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Recurrences T(n) = a T(n/b) + f(n)

• If f(n) = O(nc-) then T(n) =(nc)• If f(n) = (nc) then T(n) =(nc.log n)• If f(n) = (nc+) then T(n)=(f(n)) if a.f(n/b) d.f(n) for some d<1 and n>n0

c=logb a

T(n) = 3 T(n/2) + (n) T(n) = (nlog 3)

T(n) = 2T(n/2) + (n) T(n) = (n.log n)

2

Page 4: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

k = n/2 = MEDIAN

Split(A[1..n],x)

x x

runs in time O(n)

Page 5: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

k = n/2 = MEDIAN

Split(A[1..n],x)

x x

j

j k k-th smallest on leftj<k (k-j)-th smallest on right

Page 6: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

631

87

261

85

891

32

6 3 1 87 2 6 1 85 8 9 1 32

Page 7: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

631

87

261

85

891

32

1) sort each 5-tuple

6 3 1 87 2 6 1 85 8 9 1 32

Page 8: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

631

87

261

85

891

32

1) sort each 5-tuple

Page 9: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

261

85

891

32

1) sort each 5-tuple

Page 10: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

261

85

891

32

1) sort each 5-tuple

Page 11: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

125

86

891

32

1) sort each 5-tuple

Page 12: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

125

86

123

97

1) sort each 5-tuple

TIME = ?

Page 13: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

125

86

123

97

1) sort each 5-tuple

TIME = (n)

Page 14: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

125

86

123

97

2) find median of the middle n/5 elements

TIME = ?

Page 15: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

125

86

123

97

2) find median of the middle n/5 elements

TIME = T(n/5)

We will use this element as the pivot

Page 16: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

136

87

125

86

123

97

At least ? Many elements in the array are X

Page 17: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

123

97

At least ? Many elements in the array are X

125

86

136

87

Page 18: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

123

97

At least 3n/10 elements in the array are X

125

86

136

87

Page 19: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

123

97

At least 3n/10 elements in the array are X

125

86

136

87

6 3 1 87 2 6 1 85 8 9 1 32

Page 20: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

At least 3n/10 elements in the array are X

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87

X X

Page 21: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

At least 3n/10 elements in the array are X

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87

X X

Recurse, time ?

Page 22: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

At least 3n/10 elements in the array are X

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87

X X

Recurse, time T(7n/10)

Page 23: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

631

87

261

85

891

32

6 3 1 87 2 6 1 85 8 9 1 32

136

87

125

86

123

97

136

87

125

86

123

97

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87X X

recurse

Split

Page 24: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

631

87

261

85

891

32

6 3 1 87 2 6 1 85 8 9 1 32

136

87

125

86

123

97

136

87

125

86

123

97

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87X X

recurse

n)

T(n/5)

n)

T(7n/10)

Page 25: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

T(n) T(n/5) + T(7n/10) + O(n)

Page 26: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

T(n) T(n/5) + T(7n/10) + O(n)

T(n) d.n

Induction step:

T(n) T(n/5) + T(7n/10) + O(n) d.(n/5) + d.(7n/10) + O(n) d.n + (O(n) – dn/10) d.n

Page 27: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Why 5-tuples?

317

615

912

3 1 7 16 5 9 1 2

137

156

129

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87X X

recurse

n)n)

137

156

129

Page 28: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Why 5-tuples?

317

615

912

3 1 7 16 5 9 1 2

137

156

129

6 3 1 87 2 6 1 85 8 9 1 32

63 1 32 2 1 1 85 8 9 6 87X X

recurse

n)n)

T(2n/3)137

156

129

T(n/3)

Page 29: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Why 5-tuples?

T(n) T(n/3) + T(2n/3) + (n)

Page 30: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Why 5-tuples?

T(n) T(n/3) + T(2n/3) + (n)

T(n) c.n.ln n

Induction step:

T(n) = T(n/3) + T(2n/3) + (n) c.(n/3).ln (n/3) + c.(2n/3).ln (2n/3) + (n) c.n.ln n - c.n.((1/3)ln 3+(2/3)ln 3/2)+(n)c.n.ln n

Page 31: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Quicksort(A[b..c])

Quicksort(A[b..i]);Quicksort(A[j..c]);

Split(A[b..c],x)

x xxi jb c

Page 32: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Quicksort(A[b..c])

Worst-case running time?

How to make the worst-case running time O(n.log n) ?

Page 33: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Quicksort(A[b..c])

if pivot = medianthen the worst-case running time satisfies

T(n) = 2T(n/2) + O(n)

Page 34: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Quicksort(A[b..c])

Quicksort(A[b..i]);Quicksort(A[j..c]);

Split(A[b..c],x)

x xxi jb c

x = random element of A[b..c]

Page 35: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

k = n/2 = MEDIAN

Split(A[1..n],x)

x x

j

j k k-th smallest on leftj<k (k-j)-th smallest on right

Page 36: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finding the k-th smallest element

Select(k,A[c..d])

Split(A[c..d],x)

x x

j

j k k-th smallest on leftj<k (k-j)-th smallest on right

x=random element from A[c..d]

Page 37: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finite probability space

set (sample space)function P: R+ (probability distribution)

P(x) = 1x

Page 38: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Finite probability space

set (sample space)function P: R+ (probability distribution)

elements of are called atomic eventssubsets of are called events

probability of an event A is

P(x)xA

P(A)=

P(x) = 1x

Page 39: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Examples

1. Roll a (6 sided) dice. What is the probability that the number on the dice is even?

2. Flip two coins, what is the probability thatthey show the same symbol?

3. Flip five coins, what is the probability thatthey show the same symbol?

4. Mix a pack of 52 cards. What is the probability that all red cards come before all black cards?

Page 40: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Union bound

P(A B) P(A) + P(B)

P(A1 A2 … An) P(A1) + P(A2)+…+P(An)

LEMMA:

More generally:

Page 41: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Union bound P(A1 A2 … An) P(A1) + P(A2)+…+P(An)

Suppose that the probability of winning ina lottery is 10-6. What is the probability thatsomebody out of 100 people wins?

Ai = i-th person wins

somebody wins = ?

Page 42: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Union bound P(A1 A2 … An) P(A1) + P(A2)+…+P(An)

Suppose that the probability of winning ina lottery is 10-6. What is the probability thatsomebody out of 100 people wins?

Ai = i-th person wins

somebody wins = A1A2…A100

Page 43: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Union bound P(A1 A2 … An) P(A1) + P(A2)+…+P(An)

Suppose that the probability of winning ina lottery is 10-6. What is the probability thatsomebody out of 100 people wins?

P(A1A2…A100) 100*10-6 = 10-4

Page 44: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Union bound P(A1 A2 … An) P(A1) + P(A2)+…+P(An)

Suppose that the probability of winning ina lottery is 10-6. What is the probability thatsomebody out of 100 people wins?

P(A1A2…A100) 100*10-6 = 10-4

P(A1A2…A100) = 1–P(AC

1 AC2… AC

100) =1-P(AC

1)P(AC2)…P(AC

100) =1-(1-10-6)100 0.99*10-4

Page 45: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Independence Events A,B are independent if

P(A B) = P(A) * P(B)

Page 46: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Independence Events A,B are independent if

P(A B) = P(A) * P(B)

“observing whether B happened gives no information on A”

B

A

Page 47: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Independence Events A,B are independent if

P(A B) = P(A) * P(B)

“observing whether B happened gives no information on A”

B

AP(A|B) = P(AB)/P(B)conditional probability of A, given B

Page 48: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Independence Events A,B are independent if

P(A B) = P(A) * P(B)

P(A|B) = P(A)

Page 49: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Examples

Roll two (6 sided) dice. Let S be their sum. 1) What is that probability that S=7 ? 2) What is the probability that S=7, conditioned on S being odd ? 3) Let A be the event that S is even and B the event that S is odd. Are A,B independent? 4) Let C be the event that S is divisible by 4. Are A,C independent? 5) Let D be the event that S is divisible by 3. Are A,D independent?

Page 50: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Examples

A

BC

Are A,B independent ?Are A,C independent ?Are B,C independent ?Is it true that P(ABC)=P(A)P(B)P(C)?

Page 51: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Examples

A

BC

Are A,B independent ?Are A,C independent ?Are B,C independent ?Is it true that P(ABC)=P(A)P(B)P(C)?

Events A,B,C are pairwise independent but not (fully) independent

Page 52: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Full independence

Events A1,…,An are (fully) independentIf for every subset S[n]:={1,2,…,n}

P ( Ai ) = P(Ai)iS iS

Page 53: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Random variable

set (sample space)function P: R+ (probability distribution)

P(x) = 1x

A random variable is a function Y : RThe expected value of Y is

E[X] := P(x)* Y(x) x

Page 54: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Examples

Roll two dice. Let S be their sum.

If S=7 then player A gives player B $6otherwise player B gives player A $1

2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12

Page 55: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Examples

Roll two dice. Let S be their sum.

If S=7 then player A gives player B $6otherwise player B gives player A $1

2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12

-1 , -1,-1 ,-1, -1, 6 ,-1 ,-1 , -1 , -1 , -1

Expected income for B E[Y] = 6*(1/6)-1*(5/6)= 1/6

Y:

Page 56: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Linearity of expectation

E[X Y] E[X] + E[Y]

E[X1 X2 … Xn] E[X1] + E[X2]+…+E[Xn]

LEMMA:

More generally:

Page 57: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Linearity of expectation

Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get backthe card with your name – I pay you $10.

Let n be the number of people in the class.For what n is the game advantageous for me?

Page 58: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Linearity of expectation

Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get backthe card with your name – I pay you $10.

X1 = -9 if player 1 gets his card back 1 otherwise

E[X1] = ?

Page 59: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Linearity of expectation

Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get backthe card with your name – I pay you $10.

X1 = -9 if player 1 gets his card back 1 otherwise

E[X1] = -9/n + 1*(n-1)/n

Page 60: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Linearity of expectation

Everybody pays me $1 and writes their name on a card. I mix the cards and give everybody one card. If you get backthe card with your name – I pay you $10.

X1 = -9 if player 1 gets his card back 1 otherwise X2 = -9 if player 2 gets his card back 1 otherwise

E[X1+…+Xn] = E[X1]+…+E[Xn] = n ( -9/n + 1*(n-1)/n ) = n – 10.

Page 61: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Expected number of coin-tosses until HEADS?

Page 62: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Expected number of coin-tosses until HEADS?

1/2 1 1/4 21/8 31/16 4….

n.2-n = 2

n=1

Page 63: Administrative Sep. 25 (today) – HW3 (=QUIZ #1) due Sep. 27 – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Expected number of dice-throws until you get “6” ?