Randomized Algorithms CS648

Slides:



Advertisements
Similar presentations
Lecture Discrete Probability. 5.2 Recap Sample space: space of all possible outcomes. Event: subset of of S. p(s) : probability of element s of.
Advertisements

2 Discrete Random Variable. Independence (module 1) A and B are independent iff the knowledge that B has occurred does not change the probability that.
Randomized Algorithms Randomized Algorithms CS648 Lecture 2 Randomized Algorithm for Approximate Median Elementary Probability theory Lecture 2 Randomized.
Chapter 4 Probability and Probability Distributions
Randomized Algorithms Randomized Algorithms CS648 Lecture 3 Two fundamental problems Balls into bins Randomized Quick Sort Random Variable and Expected.
Section 7.4 (partially). Section Summary Expected Value Linearity of Expectations Independent Random Variables.
April 2, 2015Applied Discrete Mathematics Week 8: Advanced Counting 1 Random Variables In some experiments, we would like to assign a numerical value to.
Introduction to Probability
Chapter 4 Using Probability and Probability Distributions
Probability Dr. Deshi Ye Outline  Introduction  Sample space and events  Probability  Elementary Theorem.
Probability and Statistics Dr. Saeid Moloudzadeh Sample Space and Events 1 Contents Descriptive Statistics Axioms of Probability Combinatorial.
Randomized Algorithms Randomized Algorithms CS648 Lecture 6 Reviewing the last 3 lectures Application of Fingerprinting Techniques 1-dimensional Pattern.
Randomized Algorithms Randomized Algorithms CS648 Lecture 8 Tools for bounding deviation of a random variable Markov’s Inequality Chernoff Bound Lecture.
Today Today: More of Chapter 2 Reading: –Assignment #2 is up on the web site – –Please read Chapter 2 –Suggested.
Great Theoretical Ideas in Computer Science.
Quicksort!. A practical sorting algorithm Quicksort  Very efficient Tight code Good cache performance Sort in place  Easy to implement  Used in older.
1 Discrete Probability Hsin-Lung Wu Assistant Professor Advanced Algorithms 2008 Fall.
Finite probability space set  (sample space) function P:  R + (probability distribution)  P(x) = 1 x 
Information Theory and Security
Joint Probability distribution
Probability and Statistics Dr. Saeid Moloudzadeh Axioms of Probability/ Basic Theorems 1 Contents Descriptive Statistics Axioms of Probability.
Great Theoretical Ideas In Computer Science Steven Rudich, Anupam GuptaCS Spring 2004 Lecture 22April 1, 2004Carnegie Mellon University
Great Theoretical Ideas in Computer Science.
1 TABLE OF CONTENTS PROBABILITY THEORY Lecture – 1Basics Lecture – 2 Independence and Bernoulli Trials Lecture – 3Random Variables Lecture – 4 Binomial.
Slide 1 © 2002 McGraw-Hill Australia, PPTs t/a Introductory Mathematics & Statistics for Business 4e by John S. Croucher 1 n Learning Objectives –Understand.
COMPSCI 102 Introduction to Discrete Mathematics.
PROBABILITY, PROBABILITY RULES, AND CONDITIONAL PROBABILITY
Basic Principles (continuation) 1. A Quantitative Measure of Information As we already have realized, when a statistical experiment has n eqiuprobable.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 7.
Sixth lecture Concepts of Probabilities. Random Experiment Can be repeated (theoretically) an infinite number of times Has a well-defined set of possible.
AP STATISTICS Section 7.1 Random Variables. Objective: To be able to recognize discrete and continuous random variables and calculate probabilities using.
ICS 353: Design and Analysis of Algorithms
UNIT 3. OUTLINE: Sets and Subsets Set Operations the Laws of Set Theory Counting and Venn Diagrams. A First Word on Probability. The Axioms of Probability.
Great Theoretical Ideas in Computer Science for Some.
Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2006 Lecture 10 Sept. 28, 2006Carnegie Mellon University Classics.
Probability and Simulation The Study of Randomness.
Random Variables Lecture Lecturer : FATEN AL-HUSSAIN.
Theory of Computational Complexity Probability and Computing Ryosuke Sasanuma Iwama and Ito lab M1.
Section 7.3. Why we need Bayes?  How to assess the probability that a particular event occurs on the basis of partial evidence.  The probability p(F)
Great Theoretical Ideas in Computer Science.
Theory of Computational Complexity M1 Takao Inoshita Iwama & Ito Lab Graduate School of Informatics, Kyoto University.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
3 Discrete Random Variables and Probability Distributions
ECE 313 Probability with Engineering Applications Lecture 7
Chapter 6: Discrete Probability
Introduction to Discrete Mathematics
Applied Discrete Mathematics Week 11: Relations
PROBABILITY AND PROBABILITY RULES
What is Probability? Quantification of uncertainty.
CS104:Discrete Structures
Conditional Probability
PRODUCT MOMENTS OF BIVARIATE RANDOM VARIABLES
Lecture 8 Randomized Algorithms
Vapnik–Chervonenkis Dimension
An Example of {AND, OR, Given that} Using a Normal Distribution
Now it’s time to look at…
Monte Carlo Approximations – Introduction
Randomized Algorithms CS648
Hidden Markov Models Part 2: Algorithms
Randomized Algorithms CS648
Randomized Algorithms CS648
Great Theoretical Ideas In Computer Science
Great Theoretical Ideas In Computer Science
Applied Discrete Mathematics Week 12: Discrete Probability
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Lecture 2 Basic Concepts on Probability (Section 0.2)
An Example of {AND, OR, Given that} Using a Normal Distribution
Consider the following problem
Chapter 1 Probability Spaces
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

Randomized Algorithms CS648 Lecture 4 Linearity of Expectation with applications (Most important tool for analyzing randomized algorithms)

RECAP from the last lecture

Random variable Definition: A random variable defined over a probability space (Ω,P) is a mapping Ω  R. Examples: The number of HEADS when a coin is tossed 5 times. The sum of numbers seen when a dice is thrown 3 times. The number of comparisons during Randomized Quick Sort on an array of size n. Notations for random variables : X, Y, U, …(capital letters) X(ω) denotes the value of X on elementary event ω.

Expected Value of a random variable (average value) Definition: Expected value of a random variable X defined over a probability space (Ω,P) is E[X] = ωϵ Ω X(ω)⨯ P(ω) Ω X= c X= b X= a E[X] = aϵ X a⨯ P(X = a)

Examples Random experiment 1: A fair coin is tossed n times Random Variable X: The number of HEADS E[X] = 𝑖 𝑖⨯ P(X =𝑖) = 𝑖 𝑖⨯ 𝑛 𝑖 ( 1 2 ) 𝑖 ( 1 2 ) 𝑛−𝑖 = 𝑛 2 Random Experiment 2: 4 balls into 3 bins Random Variable X: The number of empty bins

Can we solve these problems ? Random Experiment 1 𝑚 balls into 𝑛 bins Random Variable X: The number of empty bins E[X]= ?? Random Experiment 2 Randomized Quick sort on 𝑛 elements Random Variable Y: The number of comparisons E[Y]= ??

Balls into Bins (number of empty bins) 1 2 3 4 5 … m-1 m Question : X is random variable denoting the number of empty bins. E[X]= ?? Attempt 1: (based on definition of expectation) E[X] = 𝑖 𝑖∙P(X =𝑖) = 𝑖 𝑖∙( 𝑛 𝑖 )∙P(a specific subset of 𝑖 bins are empty and rest are nonempty) = 𝑖 𝑖∙( 𝑛 𝑖 )∙ (1− 𝑖 𝑛 ) 𝑚 ∙(1−p(𝑛−𝑖,𝑚)) A subset of 𝑖 bins 1 2 3 … … n This is a right but useless answer !

Randomized Quick Sort (number of comparisons) Question : Y is random variable denoting the number of comparisons. E[Y]= ?? Attempt 1: (based on definition of expectation) E[Y] = 𝑖 𝑖∙P(Y =𝑖) A recursion tree associated with Randomized Quick Sort We can not proceed from this point …

Balls into Bins (number of empty bins) 1 2 3 4 5 … m-1 m 1 2 3 … … n Balls into Bins (number of empty bins) Randomized Quick Sort (number of comparisons)

Balls into Bins (number of empty bins) 1 2 3 4 5 … m-1 m Question: Let 𝑿 𝒊 be a random variable defined as follows. 𝑿 𝒊 = 1 if 𝑖th bin is empty 0 otherwise What is E[ 𝑿 𝒊 ] ? Answer : E[ 𝑿 𝒊 ] = 1 ∙ P(𝑖th bin is empty) + 0 ∙ P(𝑖th bin 𝐢𝐬 𝐧𝐨𝐭 empty) = P(𝑖th bin is empty) = (1− 1 𝑛 ) 𝑚 1 2 3 … 𝑖 … n

Balls into Bins (any relation between 𝑿 and 𝑿 𝒊 ’s ?) Consider any elementary event. 𝑿 ω =𝟐 1 2 3 4 5 6 An elementary event ω 1 2 3 4 5 𝑿 𝟏 (ω) 𝑿 𝟐 (ω) 𝑿 𝟑 (ω) 𝑿 𝟒 (ω) 𝑿 𝟓 (ω) 1 1 𝑿 ω = 𝑿 𝟏 ω + 𝑿 𝟐 ω + 𝑿 𝟑 ω + 𝑿 𝟒 ω + 𝑿 𝟓 ω

Sum of Random Variables Definition: Let 𝑼,𝑽,𝑾 be random variables defined over a probability space (Ω,P) such that 𝑼 ω = 𝑽 ω +𝑾(ω) for each ω ϵ Ω Then 𝑼 is said to be the sum of random variables 𝑽 and 𝑾. A compact notation : Definition: Let 𝑼 and 𝑽 𝟏 , 𝑽 𝟐 ,…, 𝑽 𝒏 be random variables defined over a probability space (Ω,P) such that 𝑼 ω = 𝑽 𝟏 ω + 𝑽 𝟐 ω + …+ 𝑽 𝒏 ω for each ω ϵ Ω Then 𝑼 is said to be the sum of random variables 𝑽 𝟏 , 𝑽 𝟐 ,…, 𝑽 𝒏 . 𝑼=𝑽+𝑾 𝑼= 𝑽 𝟏 + 𝑽 𝟐 +…+ 𝑽 𝒏

Randomized Quick Sort (number of comparisons) Elements of A arranged in Increasing order of values 𝑒 𝑖 Question : Let 𝒀 𝒊𝒋 , for any 1≤𝑖<𝑗≤𝑛, be a random variable defined as follows. 𝒀 𝒊𝒋 = 1 if 𝑒 𝑖 is compared with 𝑒 𝑗 during Randomized Quick Sort of A 0 otherwise What is E[ 𝒀 𝒊𝒋 ] ? Answer : E[ 𝒀 𝒊𝒋 ] = 1 ∙ P( 𝑒 𝑖 is compared with 𝑒 𝑗 ) + 0 ∙ P( 𝑒 𝑖 is 𝐧𝐨𝐭 compared with 𝑒 𝑗 ) = P( 𝑒 𝑖 is compared with 𝑒 𝑗 ) = 2 𝑗−𝑖+1

Randomized Quick Sort (any relation between 𝒀 and 𝒀 𝒊𝒋 ’s ?) Consider any elementary event. Question: What is relation between and 𝒀 ω and 𝒀 𝒊𝒋 ω ? Answer: 𝒀 ω = 𝒊<𝒋 𝒀 𝒊𝒋 ω Any elementary event ω 𝒀 𝟏𝟐 (ω) 𝒀 𝟏𝟑 (ω) … 𝒀 𝟏𝒏 (ω) 𝒀 𝟐𝟑 (ω) 𝒀 𝟐𝟒 (ω) … 𝒀 𝒏−𝟏 𝒏 (ω) 1 0 … 0 1 1 … 0 Hence 𝒀= 𝒊<𝒋 𝒀 𝒊𝒋

What have we learnt till now? Balls into Bin experiment X: random variable denoting the number of empty bins Aim: E[X]= ?? E[ 𝑿 𝒊 ] = (1− 1 𝑛 ) 𝑚 Randomized Quick Sort Y: random variable for the number of comparisons Aim: E[Y]= ?? E[ 𝒀 𝒊𝒋 ] = 2 𝑗−𝑖+1 Hence 𝒀= 𝒊<𝒋 𝒀 𝒊𝒋 𝑿= 𝒊≤𝒏 𝑿 𝒊 E[𝑿]≟ 𝒊≤𝒏 E[ 𝑿 𝒊 ] E[𝒀]≟ 𝒊<𝒋 E[ 𝒀 𝒊𝒋 ]

The main question ? 𝐄[𝑼]≟𝐄[𝑽]+𝐄[𝑾] 𝐄[𝑼]= ωϵ Ω 𝑼(ω)∙ P(ω) Let 𝑼,𝑽,𝑾 be random variables defined over a probability space (Ω,P) such that 𝑼=𝑽+𝑾, 𝐄[𝑼]≟𝐄[𝑽]+𝐄[𝑾] 𝐄[𝑼]= ωϵ Ω 𝑼(ω)∙ P(ω) = ωϵ Ω (𝑽(ω)+𝑾(ω))∙ P(ω) = ωϵ Ω ( 𝑽(ω)∙ P(ω)+𝑾(ω)∙ P(ω) ) = ωϵ Ω 𝑽(ω)∙ P(ω) + ωϵ Ω 𝑾(ω)∙ P(ω) = 𝐄[𝑽]+𝐄[𝑾]

Balls into Bins (number of empty bins) 1 2 3 4 5 … m-1 m 𝑿 : random variable denoting the number of empty bins. 𝑿= 𝒊≤𝒏 𝑿 𝒊 Using Linearity of Expectation 𝐄[𝑿] = 𝑖≤𝑛 𝐄[ 𝑿 𝒊 ] = 𝑖≤𝑛 (1− 1 𝑛 ) 𝑚 = 𝑛 (1− 1 𝑛 ) 𝑚 = 𝑛/𝑒 for 𝑚=𝑛 1 2 3 … … n

Randomized Quick Sort (number of comparisons) 𝒀: r. v. for the no. of comparisons during Randomized Quick Sort on 𝑛 elements. 𝒀= 𝒊<𝒋 𝒀 𝒊𝒋 Using Linearity of expectation: 𝐄[𝒀]= 𝑖<𝑗 𝐄[𝒀 𝑖𝑗 ] = 𝑖<𝑗 2 𝑗−𝑖+1 = 𝑖=1 𝑛 𝑗=𝑖+1 𝑛 2 𝑗−𝑖+1 =2 𝑖=1 𝑛 [ 1 2 + 1 3 + …+ 1 𝑛−𝑖+1 ] <2 𝑖=1 𝑛 [ 1+ 1 2 + 1 3 + …+ 1 𝑛 ] −2𝑛 =2𝑛 l𝑜 𝑔 𝑒 𝑛 −𝑶(𝑛) 𝑯 𝑛 ≤ l𝑜 𝑔 𝑒 𝑛 +0.58

Linearity of Expectation Theorem: (For sum of 2 random variables) If 𝑼,𝑽,𝑾 are random variables defined over a probability space (Ω,P) such that 𝑼=𝑽+𝑾, then 𝐄 𝑼 =𝐄[𝑽]+𝐄[𝑾] (For sum of more than 2 random variables) If 𝑼= 𝒊 𝑽 𝒊 , then 𝐄[𝑼]= 𝑖 𝐄[𝑽 𝑖 ]

Where to use Linearity of expectation ? Whenever we need to find E[U] but none of the following work E[𝑼] = ωϵ Ω 𝑼(ω) ∙ P(ω) E[𝑼] = aϵ 𝑼 a ∙ P(𝑼= a) In such a situation, Try to express 𝑼 as 𝒊 𝑼 𝒊 , such that it is “easy” to calculate 𝐄[𝑼 𝑖 ]. Then calculate 𝐄[𝑼] using 𝐄[𝑼]= 𝑖 𝐄[𝑼 𝑖 ]

Think over the following questions? Let 𝑼,𝑽,𝑾 be random variables defined over a probability space (Ω,P) such that 𝑼=𝒂𝑽+𝒃𝑾, for some real no. 𝒂,𝒃 then 𝐄 𝑼 ≟𝒂𝐄[𝑽]+𝒃𝐄[𝑾] Answer: yes (prove it as homework) Why does linearity of expectation holds always ? (even when 𝑽 and 𝑾 are not independent) Answer: (If you have internalized the proof of linearity of expectation, this question should appear meaningless.)

Think over the following questions? Definition: (Product of random variables) Let 𝑼,𝑽,𝑾 be random variables defined over a probability space (Ω,P) such that 𝑼 ω = 𝑽 ω ∙𝑾(ω) for each ω ϵ Ω Then 𝑼 is said to be the product of random variables 𝑽 and 𝑾. A compact notation is 𝑼=𝑽∙𝑾 If 𝑼=𝑽∙𝑾, then 𝐄 𝑼 ≟𝐄[𝑽]∙𝐄[𝑾] Answer: No (give a counterexample to establish it.) If 𝑼=𝑽∙𝑾 and both 𝑽 and 𝑾 are independent then 𝐄 𝑼 =𝐄[𝑽]∙𝐄[𝑾] Answer: Yes (prove it rigorously and find out the step which requires independence)

Independent random variables In the previous slides, we used the notion of independence of random variable. This notion is identical to the notion of independence of events: Two random variables are said to be independent if knowing the value of one random variable does not influence the probability distribution of the other. In other words, 𝐏 𝑿=𝒂 𝒀=𝒃)=𝐏(𝑿=𝒂) for all 𝒂 ϵ 𝑿 and 𝒃 ϵ 𝒀.

Some Practice problems as homework Balls into bin problem: What is the expected number of bins having exactly 2 balls ? We toss a coin n times, what is the expected number of times pattern HHT appear ? A stick has n joints. The stick is dropped on floor and in this process each joint may break with probability p independent of others. As a result the stick will be break into many substicks. What is the expected number of substicks of length 3 ? What is the expected number of all the substicks ?

Problems of the next lecture

Fingerprinting Techniques Problem 1: Given three 𝑛 ⨯ 𝑛 matrices 𝑨, 𝑩, and 𝑪, determine if 𝑪=𝑨∙𝑩. Best deterministic algorithm: 𝑫  𝑨∙𝑩 ; Verify if 𝑪=𝑫 ? Time complexity: 𝑶( 𝑛 2.37 ) Randomized Monte Carlo algorithm: Time complexity: 𝑶( 𝑛 2 𝐥𝐨𝐠 𝑛 ) Error probability: <𝑛 −𝑘 for any 𝑘.

Fingerprinting Techniques Problem 2: Given two large files A and B of 𝑛 bits located at two computers which are connected by a network. We want to determine if A is identical to B. The aim is to transmit least no. of bits to achieve it. Randomized Monte Carlo algorithm: Bits transmitted : 𝑶(𝐥𝐨𝐠 𝑛 ) Error probability: <𝑛 −𝑘 for any 𝑘.