+ All Categories
Home > Documents > Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2...

Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2...

Date post: 15-Jan-2016
Category:
View: 214 times
Download: 0 times
Share this document with a friend
Popular Tags:
33
Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)
Transcript
Page 1: Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

AdministrativeSep. 27 (today) – HW4 dueSep. 28 8am – problem session

Oct. 2Oct. 4 – QUIZ #2

(pages 45-79 of DPV)

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

Recapalgorithm for k-select with O(n) worst-case running time

modification of quick-sort which has O(n.log n) worst-case running time

randomized k-select GOAL: O(n) expected running-time

Page 3: Administrative Sep. 27 (today) – 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 4: Administrative Sep. 27 (today) – 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 5: Administrative Sep. 27 (today) – 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 6: Administrative Sep. 27 (today) – 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 7: Administrative Sep. 27 (today) – 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 8: Administrative Sep. 27 (today) – 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 9: Administrative Sep. 27 (today) – 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 10: Administrative Sep. 27 (today) – 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 11: Administrative Sep. 27 (today) – 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 12: Administrative Sep. 27 (today) – 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 13: Administrative Sep. 27 (today) – 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 14: Administrative Sep. 27 (today) – 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 15: Administrative Sep. 27 (today) – 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 16: Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

Do you expect to see the expected value?

X= 1 with probability ½3 with probability ½

E[X] =

Page 17: Administrative Sep. 27 (today) – 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?

H ½TH ¼TTH 1/8TTTH 1/16TTTTH 1/32....

Page 18: Administrative Sep. 27 (today) – 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?

n.2-n = 2

n=1

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

Page 19: Administrative Sep. 27 (today) – 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 20: Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)

FFT

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

Polynomials

p(x) = a0 + a1 x + ... + ad xd

Polynomial of degree d

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

Multiplying polynomials

p(x) = a0 + a1 x + ... + ad xd

Polynomial of degree d

q(x) = b0 + b1 x + ... + bd’ xd’

Polynomial of degree d’

p(x)q(x) = (a0b0) + (a0b1 + a1b0) x + .... + (adbd’) xd+d’

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

Polynomials

p(x) = a0 + a1 x + ... + ad xd

THEOREM: A non-zero polynomial of degree d has at most d roots.

Polynomial of degree d

COROLLARY: A polynomial of degree d is determined by its value on d+1 points.

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

COROLLARY: A polynomial of degree d is determined by its value on d+1 points.

Find a polynomial p of degree dsuch that p(a0) = 1 p(a1) = 0 .... p(ad) = 0

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

COROLLARY: A polynomial of degree d is determined by its value on d+1 points.

Find a polynomial p of degree dsuch that p(a0) = 1 p(a1) = 0 .... p(ad) = 0

(x-a1)(x-a2)...(x-ad)

(a0-a1)(a0-a2)...(a0-ad)

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

Representing polynomial of degree d

d+1 coefficients

evaluation on d+1 points

the coefficient representation

the value representation

evaluation interpolation

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

Evaluation on multiple points

p(x) = 7 + x + 5x2 + 3x3 + 6x4 + 2x5

p(z) = 7 + z + 5z2 + 3z3 + 6z4 + 2z5

p(-z) = 7 – z + 5z2 – 3z3 + 6z4 – 2z5

p(x) = (7+5x2 + 6x4) + x(1+3x2 + 2x4)p(x) = pe(x2) + x po(x2)p(-x) = pe(x2) – x po(x2)

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

Evaluation on multiple points

p(x) = a0 + a1 x + a2 x2 + ... + ad xd

p(x) = pe(x2) + x po(x2)p(-x) = pe(x2) – x po(x2)

To evaluate p(x) on -x1,x1,-x2,x2,...,-xn,xn

we only evaluate pe(x) and po(x) on x1

2,...,xn2

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

Evaluation on multiple pointsTo evaluate p(x) on -x1,x1,-x2,x2,...,-xn,xn

we only evaluate pe(x) and po(x) on x1

2,...,xn2

To evaluate pe(x) on x1

2,...,xn2

we only evaluate pe(x) on ?

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

n-th roots of unity2ik/n

e k

n = 1

k . l = k+l

0 + 1 + ... + n-1 = 0

FACT 1:

FACT 2:

FACT 3:

FACT 4:k = -k+n/2

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

FFT (a0,a1,...,an-1,) (s0,...,sn/2-1)= FFT(a0,a2,...,an-2,2) (z0,...,zn/2-1) = FFT(a1,a3,...,an-1,2)

s0 + z0

s1 + z1

s2 + 2 z2

....s0 – z0

s1 - z1 s2 - 2 z2

....

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

Evaluation of a polynomial viewed as vector mutiplication

(a0,a1,a2,...,ad)

1xx2

.

.xd

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

Evaluation of a polynomialon multiple points

(a0,a1,a2,...,ad)

1x1

x12

.

.x1

d

1x2

x22

.

.x2

d

1xn

xn2

.

.xn

d

. . .

Vandermonde matrix


Recommended