randomized algorithms cs648

38
Randomized Algorithms CS648 Lecture 9 Random Sampling part-I (Approximating a parameter) 1

Upload: nay

Post on 24-Feb-2016

27 views

Category:

Documents


0 download

DESCRIPTION

Randomized Algorithms CS648. Lecture 9 Random Sampling part-I (Approximating a parameter). Overview of the Lecture. Randomization Framework for estimation of a parameter Number of balls from a bag Size of transitive closure of a directed graph - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Randomized Algorithms CS648

Randomized AlgorithmsCS648

Lecture 9Random Sampling

part-I(Approximating a parameter)

1

Page 2: Randomized Algorithms CS648

Overview of the Lecture

Randomization Framework for estimation of a parameter1. Number of balls from a bag2. Size of transitive closure of a directed graph

• An Inspirational Problem from Continuous probability

Page 3: Randomized Algorithms CS648

AN INSPIRATIONAL PROBLEM FROM CONTINUOUS PROBABILITY

Page 4: Randomized Algorithms CS648

Question: points are selected randomly uniformly and independently from interval [0,1]. What is the expected value of the smallest number ?

We shall solve many problems dealing with random points in an interval [0,1] in this course. But we won’t require any knowledge of continuous probability theory .All we shall require is the following fact which is quite obvious:

P(point belongs to an interval of length )=

0 1𝑝 𝑝𝑝∆

Page 5: Randomized Algorithms CS648

0 1

Sampling points on a line segment

Question: What is E[ ?Answer: It appears to depend upon .

𝐗3 𝐗4𝐗𝑛+1𝐗𝑛𝐗1 𝐗2

0 1

Page 6: Randomized Algorithms CS648

Sampling points on a Circle (of circumference 1)

Question: What is E[ ?

By symmetry of the circle, each has identical probability distribution. E[]=E[]= … = E[]E[+]= ?? E[]= ??

𝐗2

𝐗3

𝐗4

𝐗𝑛

𝐗𝑛− 1𝐗1

1

1/𝑛

Page 7: Randomized Algorithms CS648

Transforming a line segment to a circle(just a different perspective)

The knot formed by joining the ends of the line segment

Give the knot a uniformly random

rotation around the circle

Page 8: Randomized Algorithms CS648

Transforming a line segment to a circle(just a different perspective)

Selecting points randomly uniformly on a unit line

Selecting points randomly uniformly on a unit circle.

𝐗2

𝐗3

𝐗4

𝐗𝑛+1

𝐗𝑛 𝐗1

First uniformly random point is the

knot.

The next points are the usual

points on the line segment.

Page 9: Randomized Algorithms CS648

0 1

We have got the answer of the problem(without any knowledge of continuous probability theory)

Question: What is E[ ?

E[] = … = E[] = … = E[] =

𝐗3 𝐗4𝐗𝑛+1𝐗𝑛𝐗1 𝐗2

0 1

Page 10: Randomized Algorithms CS648
Page 11: Randomized Algorithms CS648

ESTIMATING THE NUMBER OF BALLS IN A BAG

Page 12: Randomized Algorithms CS648

Estimating the number of Balls in a BAG

• There is a bag containing balls.• , the number of balls is unknown.• Each ball has a unique label from [1, ].

AIM: To estimate accurately and with high probability.

For example:“Report a number such that with probability at least 99%,

TOOL: Sampling

4

t

12

3

5

n

j

q :c:

i

l

l:

:

:

:::

Page 13: Randomized Algorithms CS648

Estimating the number of Balls in a BAG

IDEA: The label of a sample ball provides some info.

X: random variable for the label of a ball sampled randomly uniformly from bag.Question: What is E[X] ?Answer: E[X] =

4

t

12

3

5

n

j

q :c:

i

l

l:

:

:

:::

Can we use it to design an algorithm ?

Page 14: Randomized Algorithms CS648

Estimating the number of Balls in a BAG

A simple algorithm:1. Pick a ball randomly and uniformly from the

bag.2. Let be its label.3. .4. Report .

4

t

12

3

5

n

j

q :c:

i

l

l:

:

:

:::

Page 15: Randomized Algorithms CS648

How good is the estimate ?

Question: What is P( ) ?Answer:

Question: How to reduce the error probability ? Answer:

2 N1 N-1

multiple sampling.

𝑁 /4

Page 16: Randomized Algorithms CS648

Multiple samplings to improve accuracy and reduce error probability

Question: Which ball among the sampled balls will have label closest to ?

Question: How many of balls are expected to have label ?Answer: .

21 N

Page 17: Randomized Algorithms CS648

A better algorithm for estimating the number of balls:

1. ; // is a multiset2. Repeat times { Pick a ball randomly uniformly from the bag. Let be the its label. ; return the ball into the bag; }3. Let be the th largest label from .4. .5. Report .

Page 18: Randomized Algorithms CS648

Question: What is P( ) ?

: number of balls sampled from [1 … ]P( ) = ?? is sum of Bernoulli random variables ,…, such that

P(=1) ?? E[] = = ’s are independent.Applying Chernoff Bound, P() =

P()

21 N𝑵 /𝟒

P(>)

¼

Page 19: Randomized Algorithms CS648

Final result

Theorem: The randomized Monte Carlo performs sampling and reports a number such that with probability at least ,

Page 20: Randomized Algorithms CS648

Randomized framework for estimating a parameter

• Let be a parameter which needs to be estimated.• Design a randomized experiment such that there is a random variable

such that

• If takes value , then return ?? as the estimate for .

To improve accuracy in estimation:• repeat the experiment times. • Let has taken value ,…, .• Calculate such that is most likely to be closest to .• Return .

𝒇 −𝟏 (𝒂 )

Page 21: Randomized Algorithms CS648

ESTIMATING THE SIZE OF TRANSITIVE CLOSURE OF A DIRECTED GRAPH

Page 22: Randomized Algorithms CS648

Estimating size of Transitive Closure of a Directed Graph

Let be a directed graph on vertices and edges, For any , Reach() = { | is reachable from }. = |Reach()|

Problem: Given a directed graph on vertices and edges, compute for each .

Applications: (Graph based Data bases)1. Query requires collecting information stored at nodes reachable from a given node.2. An estimate on the number of nodes reachable can be used to get an estimate on

the time (or processing) required to answer the query. 3. This estimate can be used for optimizing a set of queries to be answered.

Page 23: Randomized Algorithms CS648

Estimating size of Transitive Closure of a Directed Graph

Problem: Given a directed graph on vertices and edges, compute for each .

Deterministic Algorithm1. Perform DFS/BFS from each to compute Reach().2. |Reach()|;3. Return .

Time complexity: O()

Page 24: Randomized Algorithms CS648

Estimating size of Transitive Closure of a Directed Graph

Problem: Given a directed graph on vertices and edges, compute for each .

Randomized Monte Carlo Algorithm1. For any and every vertex , computes such that

() ()

2. Error Probability < for any constant 3. Time complexity: O(() )

Page 25: Randomized Algorithms CS648

Randomized Monte Carlo Algorithm for estimating the size of transitive closure of directed graph

Ingredients

1. A Deterministic O() time algorithm for a problem “MinLabel”.

2. Inference from the inspirational probability problem we discussed today.

Page 26: Randomized Algorithms CS648

MIN-Label Problem

Given a directed graph on vertices and edges, where each each stores a real number for each ,

Problem: Given a directed graph on vertices and edges, and array (), compute for each .

Page 27: Randomized Algorithms CS648

MIN-Label Problem

Algorithm1 1. Compute : the graph obtained by reversing all edge directions.2. Sort vertices in the increasing order of their () value.3. Repeat until ?? { Pick vertex of least () value; Let it be ; Perform DFS/BFS to compute ; For each vertex , (); Remove from }

Time complexity: O()

Is empty

Page 28: Randomized Algorithms CS648

MIN-Label Problem

Algorithm2 (usually many problems are easier on Directed acyclic graphs)

1. Compute Strongly connected components of .2. Build DAG (directed acyclic graph) from after converting each SCC to a

vertex.3. Solve the problem on this DAG using DFS/BFS.

Time complexity: O()

Page 29: Randomized Algorithms CS648

Inference from the inspirational problem

If numbers are selected randomly uniformly and independently from [0,1], the expected value of the smallest number is = .

Question: If some numbers were selected randomly uniformly and independently from [0,1], and the smallest among them is , then what is a right guess for the numbers selected ?

Answer: ??1𝑡 −1

Page 30: Randomized Algorithms CS648

RANDOMIZED MONTE CARLO ALGORITHM FOR ESTIMATING THE SIZE OF

TRANSITIVE CLOSURE OF A DIRECTED GRAPH

Page 31: Randomized Algorithms CS648

𝑥

Page 32: Randomized Algorithms CS648

𝑥

0.45

0.71

0.220.53

0.830.38

Page 33: Randomized Algorithms CS648

0.34

0.14

0.45

0.71

0.220.53

0.83

0.28

0.9010.65

0.265

0.490.54

0.74

0.38

0.81

0.63

Page 34: Randomized Algorithms CS648

Estimating size of Transitive Closure of a Directed Graph

A simple algorithm:

1. Assign to each a random no. () selected uniformly and independently from [0,1].

2. Compute minL() for each ;

3. () ??

4. Return .

𝟏minL (𝒗 ) −𝟏

Page 35: Randomized Algorithms CS648

Estimating size of Transitive Closure of a Directed Graph

A better algorithm:For to do

{ 1. Assign to each a random no. selected uniformly and independently from [0,1].

2. Compute minL() for each ;

3. ] minL();}

() ??

Return .

Page 36: Randomized Algorithms CS648

Question 1: Which value among ], …, } is likely to be closest to ?

Question 2: How many of], …, } are likely to have value ?

Question 3: What is the probability that ] for any fixed is Answer: (Hint: for this to happen all vertices in Reach() must get () )

This probability is = ≈

0 1

Can you answer Question 2 now ?𝒌𝒆

Page 37: Randomized Algorithms CS648

Estimating size of Transitive Closure of a Directed Graph

A better algorithm:For to do { 1. Assign to each a random no. selected uniformly and independently from [0,1].

2. Compute minL() for each ;

3. ] minL();}min*() (th largest value among ], …, } ;

() ;

Return .

Page 38: Randomized Algorithms CS648

Homework

Use Chernoff bound to get a high probability bound on the error.Hint: Proceed along similar lines as in the case of estimating number of balls in a bag.

Make sincere attempts to do this homework. I shall discuss the same briefly in the beginning of the next class.