Download presentation
Presentation is loading. Please wait.
1
Administrative Sep. 27 (today) – HW4 due Sep. 28 8am – problem session Oct. 2 Oct. 4 – QUIZ #2 (pages 45-79 of DPV)
2
Recap algorithm 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
3
Finding the k-th smallest element Select(k,A[c..d]) Split(A[c..d],x) xx xx j j k k-th smallest on left j<k (k-j)-th smallest on right x=random element from A[c..d]
4
Finite probability space set (sample space) function P: R + (probability distribution) elements of are called atomic events subsets of are called events probability of an event A is P(x) xAxA P(A)= P(x) = 1 x
5
Examples A B C Are A,B independent ? Are A,C independent ? Are B,C independent ? Is it true that P(A B C)=P(A)P(B)P(C)?
6
Examples A B C Are A,B independent ? Are A,C independent ? Are B,C independent ? Is it true that P(A B C)=P(A)P(B)P(C)? Events A,B,C are pairwise independent but not (fully) independent
7
Full independence Events A 1,…,A n are (fully) independent If for every subset S [n]:={1,2,…,n} P ( A i ) = P(A i ) iSiS iSiS
8
Random variable set (sample space) function P: R + (probability distribution) P(x) = 1 x A random variable is a function Y : R The expected value of Y is E[X] := P(x)* Y(x) x
9
Examples Roll two dice. Let S be their sum. If S=7 then player A gives player B $6 otherwise player B gives player A $1 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
10
Examples Roll two dice. Let S be their sum. If S=7 then player A gives player B $6 otherwise 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:
11
Linearity of expectation E[X Y] E[X] + E[Y] E[X 1 X 2 … X n ] E[X 1 ] + E[X 2 ]+…+E[X n ] LEMMA: More generally:
12
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 back the 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?
13
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 back the card with your name – I pay you $10. X 1 = -9 if player 1 gets his card back 1 otherwise E[X 1 ] = ?
14
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 back the card with your name – I pay you $10. X 1 = -9 if player 1 gets his card back 1 otherwise E[X 1 ] = -9/n + 1*(n-1)/n
15
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 back the card with your name – I pay you $10. X 1 = -9 if player 1 gets his card back 1 otherwise X 2 = -9 if player 2 gets his card back 1 otherwise E[X 1 +…+X n ] = E[X 1 ]+…+E[X n ] = n ( -9/n + 1*(n-1)/n ) = n – 10.
16
Do you expect to see the expected value? X= 1 with probability ½ 3 with probability ½ E[X] =
17
Expected number of coin-tosses until HEADS? H ½ TH ¼ TTH 1/8 TTTH 1/16 TTTTH 1/32....
18
Expected number of coin-tosses until HEADS? n.2 -n = 2 n=1 Expected number of dice-throws until you get “6” ?
19
Finding the k-th smallest element Select(k,A[c..d]) Split(A[c..d],x) xx xx j j k k-th smallest on left j<k (k-j)-th smallest on right x=random element from A[c..d]
20
FFT
21
Polynomials p(x) = a 0 + a 1 x +... + a d x d Polynomial of degree d
22
Multiplying polynomials p(x) = a 0 + a 1 x +... + a d x d Polynomial of degree d q(x) = b 0 + b 1 x +... + b d’ x d’ Polynomial of degree d’ p(x)q(x) = (a 0 b 0 ) + (a 0 b 1 + a 1 b 0 ) x +.... + (a d b d’ ) x d+d’
23
Polynomials p(x) = a 0 + a 1 x +... + a d x d 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.
24
COROLLARY: A polynomial of degree d is determined by its value on d+1 points. Find a polynomial p of degree d such that p(a 0 ) = 1 p(a 1 ) = 0.... p(a d ) = 0
25
COROLLARY: A polynomial of degree d is determined by its value on d+1 points. Find a polynomial p of degree d such that p(a 0 ) = 1 p(a 1 ) = 0.... p(a d ) = 0 (x-a 1 )(x-a 2 )...(x-a d ) (a 0 -a 1 )(a 0 -a 2 )...(a 0 -a d )
26
Representing polynomial of degree d d+1 coefficients evaluation on d+1 points the coefficient representation the value representation evaluationinterpolation
27
Evaluation on multiple points p(x) = 7 + x + 5x 2 + 3x 3 + 6x 4 + 2x 5 p(z) = 7 + z + 5z 2 + 3z 3 + 6z 4 + 2z 5 p(-z) = 7 – z + 5z 2 – 3z 3 + 6z 4 – 2z 5 p(x) = (7+5x 2 + 6x 4 ) + x(1+3x 2 + 2x 4 ) p(x) = p e (x 2 ) + x p o (x 2 ) p(-x) = p e (x 2 ) – x p o (x 2 )
28
Evaluation on multiple points p(x) = a 0 + a 1 x + a 2 x 2 +... + a d x d p(x) = p e (x 2 ) + x p o (x 2 ) p(-x) = p e (x 2 ) – x p o (x 2 ) To evaluate p(x) on -x 1,x 1,-x 2,x 2,...,-x n,x n we only evaluate p e (x) and p o (x) on x 1 2,...,x n 2
29
Evaluation on multiple points To evaluate p(x) on -x 1,x 1,-x 2,x 2,...,-x n,x n we only evaluate p e (x) and p o (x) on x 1 2,...,x n 2 To evaluate p e (x) on x 1 2,...,x n 2 we only evaluate p e (x) on ?
30
n-th roots of unity 2 ik/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
31
FFT (a 0,a 1,...,a n-1, ) (s 0,...,s n/2-1 )= FFT(a 0,a 2,...,a n-2, 2 ) (z 0,...,z n/2-1 ) = FFT(a 1,a 3,...,a n-1, 2 ) s 0 + z 0 s 1 + z 1 s 2 + 2 z 2.... s 0 – z 0 s 1 - z 1 s 2 - 2 z 2....
32
Evaluation of a polynomial viewed as vector mutiplication (a 0,a 1,a 2,...,a d ) 1xx2..xd1xx2..xd
33
Evaluation of a polynomial on multiple points (a 0,a 1,a 2,...,a d ) 1x1x12..x1d1x1x12..x1d 1x2x22..x2d1x2x22..x2d 1xnxn2..xnd1xnxn2..xnd... Vandermonde matrix
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.