CSE 548: Analysis of Algorithms. Lectures 18, 19, 20 & 21 ( Randomized Algorithms & High Probability Bounds )

Similar documents
Randomized Algorithms

Theorem 1.7 [Bayes' Law]: Assume that,,, are mutually disjoint events in the sample space s.t.. Then Pr( )

CSE 613: Parallel Programming. Lecture 9 ( Divide-and-Conquer: Partitioning for Selection and Sorting )

Lecture 1 : Probabilistic Method

CPSC 536N: Randomized Algorithms Term 2. Lecture 2

Random Variable. Pr(X = a) = Pr(s)

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Nov 30. Final In-Class Exam. ( 7:05 PM 8:20 PM : 75 Minutes )

The first bound is the strongest, the other two bounds are often easier to state and compute. Proof: Applying Markov's inequality, for any >0 we have

CSE548, AMS542: Analysis of Algorithms, Spring 2014 Date: May 12. Final In-Class Exam. ( 2:35 PM 3:50 PM : 75 Minutes )

CSE525: Randomized Algorithms and Probabilistic Analysis April 2, Lecture 1

CSE 525 Randomized Algorithms & Probabilistic Analysis Spring Lecture 3: April 9

Lecture 2 Sep 5, 2017

Chernoff Bounds. Theme: try to show that it is unlikely a random variable X is far away from its expectation.

Lecture 2: Randomized Algorithms

Introduction to Randomized Algorithms: Quick Sort and Quick Selection

N/4 + N/2 + N = 2N 2.

CSE 613: Parallel Programming. Lecture 8 ( Analyzing Divide-and-Conquer Algorithms )

CS155: Probability and Computing: Randomized Algorithms and Probabilistic Analysis

Quick Sort Notes , Spring 2010

CMPUT 675: Approximation Algorithms Fall 2014

Essentials on the Analysis of Randomized Algorithms

CS261: A Second Course in Algorithms Lecture #18: Five Essential Tools for the Analysis of Randomized Algorithms

Design and Analysis of Algorithms

X = X X n, + X 2

ELEG 3143 Probability & Stochastic Process Ch. 2 Discrete Random Variables

Randomized algorithms. Inge Li Gørtz

Analysis of Algorithms CMPSC 565

Kousha Etessami. U. of Edinburgh, UK. Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 7) 1 / 13

11.1 Set Cover ILP formulation of set cover Deterministic rounding

13. RANDOMIZED ALGORITHMS

Lecture 5: January 30

CS5314 Randomized Algorithms. Lecture 18: Probabilistic Method (De-randomization, Sample-and-Modify)

Lecture 4: Sampling, Tail Inequalities

CSE 613: Parallel Programming. Lectures ( Analyzing Divide-and-Conquer Algorithms )

Randomized Complexity Classes; RP

Probability Density Functions and the Normal Distribution. Quantitative Understanding in Biology, 1.2

Advanced Algorithms (2IL45)

Randomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th

13. RANDOMIZED ALGORITHMS

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 20

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 3 Luca Trevisan August 31, 2017

Lower Bounds for Testing Bipartiteness in Dense Graphs

CSE613: Parallel Programming, Spring 2012 Date: May 11. Final Exam. ( 11:15 AM 1:45 PM : 150 Minutes )

Data Mining. Chapter 5. Credibility: Evaluating What s Been Learned

Randomization in Algorithms

Advanced Combinatorial Optimization Feb 13 and 25, Lectures 4 and 6

Randomized Algorithms I. Spring 2013, period III Jyrki Kivinen

Basic Probability. Introduction

CS 580: Algorithm Design and Analysis

1.225J J (ESD 205) Transportation Flow Systems

Example 1. The sample space of an experiment where we flip a pair of coins is denoted by:

CSE 312 Final Review: Section AA

Chapter 13. Randomized Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

COMP2610/COMP Information Theory

An Introduction to Randomized algorithms

CS 580: Algorithm Design and Analysis

Lecture 24: April 12

Chapter 3. Chapter 3 sections

Theorem 2.1 (Caratheodory). A (countably additive) probability measure on a field has an extension. n=1

Name: Firas Rassoul-Agha

Homework 4 Solutions

Exponential Tail Bounds

Tail Inequalities Randomized Algorithms. Sariel Har-Peled. December 20, 2002

CMPSCI 240: Reasoning Under Uncertainty

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

1 Terminology and setup

1. Discrete Distributions

Model Counting for Logical Theories

Application: Bucket Sort

Copyright 2000, Kevin Wayne 1

SUFFICIENT STATISTICS

Randomized Algorithms III Min Cut

Errata for the ASM Study Manual for Exam P, Fourth Edition By Dr. Krzysztof M. Ostaszewski, FSA, CFA, MAAA

Notes 6 : First and second moment methods

Lecture 5: Probabilistic tools and Applications II

Assignment 4: Solutions

EE514A Information Theory I Fall 2013

Random Number Generators

F 99 Final Quiz Solutions

CSC 446 Notes: Lecture 13

Bernoulli Trials, Binomial and Cumulative Distributions

Lecture 4: Probability and Discrete Random Variables

Page Max. Possible Points Total 100

Expectation, inequalities and laws of large numbers

Outline. CS38 Introduction to Algorithms. Max-3-SAT approximation algorithm 6/3/2014. randomness in algorithms. Lecture 19 June 3, 2014

Continuous-Valued Probability Review

CS 125 Section #12 (More) Probability and Randomized Algorithms 11/24/14. For random numbers X which only take on nonnegative integer values, E(X) =

Quicksort (CLRS 7) We previously saw how the divide-and-conquer technique can be used to design sorting algorithm Merge-sort

The Probabilistic Method

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

CS161: Algorithm Design and Analysis Recitation Section 3 Stanford University Week of 29 January, Problem 3-1.

Lecture 1: Contraction Algorithm

CSE 312: Foundations of Computing II Quiz Section #10: Review Questions for Final Exam (solutions)

Ma/CS 6b Class 15: The Probabilistic Method 2

Chapter 11. Min Cut Min Cut Problem Definition Some Definitions. By Sariel Har-Peled, December 10, Version: 1.

The Monte Carlo Method

Lecture 4: Two-point Sampling, Coupon Collector s problem

Lecture Notes CS:5360 Randomized Algorithms Lecture 20 and 21: Nov 6th and 8th, 2018 Scribe: Qianhang Sun

ACO Comprehensive Exam October 14 and 15, 2013

Transcription:

CSE 548: Analysis of Algorithms Lectures 18, 19, 20 & 21 ( Randomized Algorithms & High Probability Bounds ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Fall 2012

Markov s Inequality Theorem 1:Let be a random variable that assumes only nonnegative values. Then for all 0, Pr. Proof:For 0, let Since 0,. 1 if ; 0 otherwise. We also have, Pr 1 Pr. Then Pr.

Example: Coin Flipping Let us bound the probability of obtaining more than sequence of fair coin flips. heads in a Let 1 if the th coin flip is heads; 0 otherwise. Then the number of heads in flips, We know, Pr 1.. Hence,. Then applying Markov s inequality, Pr.

Theorem 2:For any 0, Chebyshev s Inequality Pr. Proof:Observe that Pr Pr. Since is a nonnegative random variable, we can use Markov s inequality, Pr.

Example: Fair Coin Flips 1 if the th coin flip is heads; 0 otherwise. Then the number of heads in flips,. We know, Pr 1 and. Then. Hence, and Then applying Chebyshev s inequality, Pr Pr..

Coin Flipping and Randomized Algorithms Suppose we have an algorithm that is correct ( heads ) only with probability 0,1, and incorrect ( tails ) with probability 1. Question:How many times should we run the algorithm to be reasonably confident that it returns at least one correct solution? Las Vegas Algorithm: You keep running the algorithm until you get a correct solution. What is the bound on running time? Monte Carlo Algorithm: You stop after a certain number of iterations no matter whether you found a correct solution or not. What is the probability that your solution is correct ( or you found a solution )?

Coin Flipping and Randomized Algorithms Suppose we have an algorithm that is correct ( heads ) only with probability 0,1, and incorrect ( tails ) with probability 1. Suppose we run the algorithm times. Then probability that no run produces a correct solution is 1. probability of getting at least one correct solution is 1 1. Set ln, where 1and 0is a constant. Then the probability that at least one run produces a correct solution is 1 1 1. An event Πis said to occur with high probability if Pr Π 1. w.h.p.

Example: A Coloring Problem Let be a set of items. For 1, let such that for every pair of, 1, with, but not necessarily. For each 1,, let, where 2. Problem:Color each item of with one of two colors, redand blue, such that each contains at least one redand one blueitem. Algorithm:Take each item of and color it either redor blue independently at random ( with probability ). Clearly, the algorithm does not always lead to a valid coloring ( i.e., satisfy the constraints given in our problem statement ). What is the probability that it produces a valid coloring?

Example: A Coloring Problem For 1, let and be the events that all items of are colored red and blue, respectively. Then Pr Pr 2 for every 1,. Pr Pr 2 2 2. Thus Pr 2. Pr 1 Pr 1. Hence, the algorithm is correct with probability at least. To check if the algorithm has produced a correct result we simply check the items in each to verify that neither nor holds. Hence, we can use this simple algorithm to design a Las Vegas algorithm for solving the coloring problem!

Example: The Min-Cut Problem Let, be a connected, undirected multigraphwith. A cutin is a set, such that, is not connected. A min-cutis a cut of minimum cardinality. The multigraphon the right has a min-cut of size 2:,,, and,,,. Most deterministic algorithms for finding min-cuts are based on network flows and hence are quite complicated. Instead in this lecture we will look at a very simple probabilistic algorithm that finds min-cuts with some probability 0.

Example: The Min-Cut Problem We apply the following contraction step 2times on, : Select an edge ( say,, ) from uniformly at random. Merge and into a single super vertex. Remove all edges between and from. If as a result of the contraction there are more than one edges between some pairs of super vertices retain them all. Let the initial graph be,, where and. Let, be the multigraphafter step 1, 2. Then clearly, and thus 2. We return as our solution.

Example: The Min-Cut Problem Let us fix our attention on a particular min-cut of. What is the probability that? Suppose. Then each vertex of must have degree at least as otherwise can be disconnected by removing fewer than edges. Hence, /2 /2. Let Π be the event of not picking an edge of for contraction in step 1, 2. Then clearly, Pr Π 1 1 1 / Also Pr Π Π 1 1 / In general, Pr Π Π 1 1 1 / 1

Example: The Min-Cut Problem The probability that no edge of was ever picked by the algorithm is: Pr Π 1. So Pr, and Pr 1. Suppose we run the algorithm /2times, and return the smallest cut, say, obtained from those /2attempts. Then Pr 1 / Pr 1. Hence, the algorithm will return a min-cut with probability 1. But we do not know how to detect if the cut returned by the algorithm is, indeed, a min-cut. Still we can design a Monte-Carlo algorithm based on this simple idea to produce a min-cut with high probability!

When Only One Success is Not Enough In both examples we have looked at so far, we were happy with only one success. The analysis was easy. But sometimes we need the algorithm to be successful for at least or at most a certain number of times ( we will see a very familiar such example shortly ). The number of successful runs required often depends on the size of the input. How do we analyze those algorithms?

The binomial distribution is the discrete probability distribution of the #successes in a sequence of independent yes/no experiments (i.e., Bernoulli trials), each of which succeeds with probability. Binomial Distribution Source Prof. Nick Harvey ( UBC ) Probability mass function: ;, Pr 1, 0 Cumulative distribution function: RED:Binomial distribution with 20and ;, Pr 1, 0

Approximating with Normal Distribution Normal distribution with mean and variance is given by: ;, 1 2, R For fixed as increases the binomial distribution with parameters and is well approximated by a normal distribution with and 1. RED: Binomial distribution with Source Prof. Nick Harvey ( UBC ) 20and BLUE: Normal distribution with 10 and 1 5

Approximating with Normal Distribution Normal distribution with mean and variance is given by: ;, 1 2 The probability that a normally distributed random variable lies in the interval, is given by:, R ;, 1 erf where, erf But erf cannot be expressed in closed form in terms of elementary functions, and hence difficult to evaluate.., Source Prof. Nick Harvey ( UBC )

Approximating with Poisson Distribution Poisson distribution with mean 0is given by: ;, 0,1,2,! If is fixed and increases the binomial distribution with parameters and is well approximated by a Poisson distribution with. RED: Binomial distribution with Source Prof. Nick Harvey ( UBC ) 50and BLUE: Poisson distribution with 200 Observe that the asymmetry in the plot cannot be well approximated by a symmetric normal distribution.

Preparing for Chernoff Bounds Lemma 1:Let,, be independent Poisson trials, that is, each is a 0-1 random variable with Pr 1 for some. Let and. Then for any 0, Proof:. 1 1 1 1 But for any, 1. Hence,. Now,. But, Hence,.

Chernoff Bound 1 Theorem 3:Let,, be independent Poisson trials, that is, each is a 0-1 random variable with Pr 1 for some. Let and. Then for any 0, Pr 1 Proof:Applying Markov s inequality for any 0, Pr 1 Pr [ Lemma 1 ] Setting ln 1 0, i.e., 1, we get, Pr 1..

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for.

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for.

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for. Hence, first decreases and then increases over 0,1. Since 0 0and 1 0, we have 0over 0,1.

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for. Hence, first decreases and then increases over 0,1. Since 0 0and 1 0, we have 0over 0,1.

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for. Hence, first decreases and then increases over 0,1. Since 0 0and 1 0, we have 0over 0,1. Since 0 0,it follows that 0in that interval.

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for. Hence, first decreases and then increases over 0,1. Since 0 0and 1 0, we have 0over 0,1. Since 0 0,it follows that 0in that interval.

Chernoff Bound 2 Theorem 4: For 0 1, Pr 1. Proof:From Theorem 3, for 0, Pr 1. We will show that for 0 1, 1 ln 1 That is, 1 ln 1 0 We have, ln 1, and Observe that 0for 0, and 0for. Hence, first decreases and then increases over 0,1. Since 0 0and 1 0, we have 0over 0,1. Since 0 0,it follows that 0in that interval.

Chernoff Bound 3 Corollary 1: For 0, Pr. Proof:From Theorem 2, for 0 1, Pr 1. Setting, we get, Pr for 0.

Example: Fair Coin Flips 1 if the th coin flip is heads; 0 otherwise. Then the number of heads in flips, We know, Pr 1. Hence,.. Now putting in Chernoffbound 2, we have, Pr.

Chernoff Bounds 4, 5 and 6 Theorem 5:For 0 1, Pr 1. Theorem 6: For 0 1, Pr 1. Corollary 2: For 0, Pr.

Chernoff Bounds Lower Tail Upper Tail : Pr 1 1 : Pr 1 1 : Pr 1 : Pr : Pr 1 : Pr Source greedyalgs.info

Randomized Quicksort ( RANDQS )

Randomized Quicksort ( RANDQS ) Input:A set of numbers. ( i.e., all numbers are distinct ) Output:The numbers of sorted in increasing order. Steps: 1. Pivot Selection:Select a number uniformly at random. 2. Partition: Compare each number of with, and determine sets and. 3. Recursion: Recursively sort and. 4. Output:Output the sorted version of, followed by, followed by the sorted version of.

Randomized Quicksort ( RANDQS ) Assumption:RANDQSis called only on nonempty. Observation:If, fewer than recursive calls to RANDQSwill be made during the sorting of. ( why? ) Observation:If,and is the total number of comparisons made in step 2 ( Partition ) across all ( original and recursive ) calls to RANDQS,then RANDQSsorts in Ο time.

Expected Running Time of RANDQS Observation:If,and is the total number of comparisons made in step 2 ( Partition ) across all ( original and recursive ) calls to RANDQS,then RANDQSsorts in Ο time. Then all we need to do is determine. Let,,, be the elements of in sorted order. Let,,, for all 1. Observe that each pair of elements of is compared at most once during the entire execution of the algorithm. ( why? ) For 1, let 1 if is compared to ; 0 otherwise.. Then

Expected Running Time of RANDQS For 1, let 1 if is compared to ; 0 otherwise. Then Pr 1 Observations: :Once a pivot with is chosen, and will never be compared at any subsequent time. ( why? ) :If either or is chosen as a pivot before any other item in then will be compared with.( why? )

Expected Running Time of RANDQS Since each element of is equally likely to be chosen as a pivot: Pr 1 Hence, Pr 1 Ο log Ο log. Thus expected running time of RANDQSis Ο log.

High Probability Bound for RANDQS We will prove that w.h.p. the running time of RANDQSdoes not exceed its expected running time by more than a constant factor. In other words, we show that w.h.p. RANDQSruns in Ο log time.

High Probability Bound for RANDQS Let us fix an element in the original input set of size. We will trace the partition containing for ln levels of recursion, where is a constant to be determined later. If a partitioning step divides such that, that partition a balanced partition., we call

High Probability Bound for RANDQS We will prove that among the ln partitioning steps undergoes, w.h.p. at least ln results in balanced partitions. If at any point is in a partition of size, after a balanced partitioning step it ends up in a partition of size at most. Since the input size is, after ln balanced partitions, will end up in a partition of size, which is 1for 14. That means if 14, then will end up in its final sorted position in the output after undergoing ln balanced partitions.

High Probability Bound for RANDQS For 1 ln, let 1 if the partition at recursion level is balanced; 0 otherwise. But a balanced partition is obtained by choosing a pivot with rank between and, where is the size of the set being partitioned. Since each element of the set is chosen as a pivot uniformly at random, a balancing pivot will be chosen with probability Hence, Pr 1. Thus Pr 1..

High Probability Bound for RANDQS Total number of balanced partitions,. Then. Now applying Chernoffbound 5 ( see Theorem 6 ) with, Pr 1 Pr ln. For 32, we have Pr 8 ln. This means that the probability that fails to reach its final sorted position even after 32 ln levels of recursion is.

High Probability Bound for RANDQS The probability that at least one of input elements fails to reach its final sorted position after 32 ln levels of recursion is. the probability that all input elements reach their final sorted positions after 32 ln levels of recursion is 1. But observe that the total amount of work done in each level of recursion is Ο. total work done in 32 ln levels of recursion is Ο log. Hence, w.h.p. RANDQSterminates in Ο log time.

Random Skip Lists

Traditional Linked List: Searching in a Sorted Linked List 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 SEARCH : Takes time. items 2-level Linked List: 2 11 25 38 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 SEARCH : Takes 2 time.

3-level Linked List: Searching in a Sorted Linked List SEARCH : Takes 3 time. -level Linked List: SEARCH takes time. For : SEARCH takes log 2 log time!

Searching in a Sorted Linked List -level Linked List: SEARCHtakes log 2 log time! 2 5 2 25 4 2 11 25 38 3 2 6 11 18 25 31 38 46 2 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 1 Observations: items 1. Let #items in level. Then. 2. Let = #items in level that have not reached level 1. Then.

Searching in a Sorted Linked List -level Linked List: SEARCHtakes log 2 log time! 2 5 2 25 4 2 11 25 38 3 2 6 11 18 25 31 38 46 2 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 1 items How do we maintain this regular structure under insertion and deletion of items? Deterministic solution does not seem straightforward. But randomization can make life really easy!

Random Skip Lists 18 5 5 18 31 4 5 18 31 38 3 5 11 18 20 31 38 51 2 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 1 Construction: 1. Start with all items along with a sentinel in level 1. 2. Promote each non-sentinel item of level 0to level 1 with probability. If level 1is nonempty promote the sentinel, too.

Random Skip Lists 18 5 5 18 31 4 5 18 31 38 3 5 11 18 20 31 38 51 2 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 1 Let be a skip list, be the set of all items in level 1, max, and max.

Random Skip Lists 18 5 5 18 31 4 5 18 31 38 3 5 11 18 20 31 38 51 2 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 1 Clearly, for each and 1, Pr. Then Pr Pr Pr Pr. Pr 1 Pr 1. For constant 2, Pr log 1 Hence, w.h.p. height of a skip list is Ο log.. 1.

Random Skip Lists 5 18 5 18 31 4 5 18 31 38 3 5 11 18 20 31 38 51 2 2 5 6 8 11 15 18 20 25 27 31 32 38 42 46 51 1 Let us flip 4 log fair coins, and let is the number of heads we get. Then 4 log 2 log. We know for 0 1, Chernoffbound, Pr 1. Putting and 2 log, we get, Pr log For 16, Pr log 1. Hence, w.h.p. we will get more than log heads..