141
Outline Monte Carlo Method Vamshi Krishna Vudepu 1 1 Lane Department of Computer Science and Electrical Engineering West Virginia University 05 April, 2012 Vamshi Randomized Algorithms 1of 26

Monte Carlo Method - West Virginia University

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Monte Carlo Method - West Virginia University

Outline

Monte Carlo Method

Vamshi Krishna Vudepu1

1Lane Department of Computer Science and Electrical EngineeringWest Virginia University

05 April, 2012

Vamshi Randomized Algorithms 1of 26

Page 2: Monte Carlo Method - West Virginia University

Outline

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 2of 26

Page 3: Monte Carlo Method - West Virginia University

Outline

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 2of 26

Page 4: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 3of 26

Page 5: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

What is a Monte Carlo Method?

The Monte Carlo Method refers to a collection of tools for evaluating values throughsampling and simulation.

Why Monte Carlo Method?

(i) Used when inputs are uncertain and are specified as probability distribution.

(ii) Predicts output values based on input samples.

Vamshi Randomized Algorithms 4of 26

Page 6: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

What is a Monte Carlo Method?

The Monte Carlo Method refers to a collection of tools for evaluating values throughsampling and simulation.

Why Monte Carlo Method?

(i) Used when inputs are uncertain and are specified as probability distribution.

(ii) Predicts output values based on input samples.

Vamshi Randomized Algorithms 4of 26

Page 7: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

What is a Monte Carlo Method?

The Monte Carlo Method refers to a collection of tools for evaluating values throughsampling and simulation.

Why Monte Carlo Method?

(i) Used when inputs are uncertain and are specified as probability distribution.

(ii) Predicts output values based on input samples.

Vamshi Randomized Algorithms 4of 26

Page 8: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

What is a Monte Carlo Method?

The Monte Carlo Method refers to a collection of tools for evaluating values throughsampling and simulation.

Why Monte Carlo Method?

(i) Used when inputs are uncertain and are specified as probability distribution.

(ii) Predicts output values based on input samples.

Vamshi Randomized Algorithms 4of 26

Page 9: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

What is a Monte Carlo Method?

The Monte Carlo Method refers to a collection of tools for evaluating values throughsampling and simulation.

Why Monte Carlo Method?

(i) Used when inputs are uncertain and are specified as probability distribution.

(ii) Predicts output values based on input samples.

Vamshi Randomized Algorithms 4of 26

Page 10: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

General steps involved in Monte Carlo Methods

(i) Define a domain of possible inputs.

(ii) Choose inputs at random from the probability distribution over the domain.

(iii) Perform computation on inputs and aggregate the results.

Vamshi Randomized Algorithms 5of 26

Page 11: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

General steps involved in Monte Carlo Methods

(i) Define a domain of possible inputs.

(ii) Choose inputs at random from the probability distribution over the domain.

(iii) Perform computation on inputs and aggregate the results.

Vamshi Randomized Algorithms 5of 26

Page 12: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

General steps involved in Monte Carlo Methods

(i) Define a domain of possible inputs.

(ii) Choose inputs at random from the probability distribution over the domain.

(iii) Perform computation on inputs and aggregate the results.

Vamshi Randomized Algorithms 5of 26

Page 13: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

General steps involved in Monte Carlo Methods

(i) Define a domain of possible inputs.

(ii) Choose inputs at random from the probability distribution over the domain.

(iii) Perform computation on inputs and aggregate the results.

Vamshi Randomized Algorithms 5of 26

Page 14: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 15: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations?

Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 16: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators.

Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 17: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin.

The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 18: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively.

A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 19: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball.

We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 20: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input.

If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 21: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked.

For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 22: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definition

Sampling

How can you ensure that an input is selected uniformly at random from the given inputdomain in Computer Simulations? Using Random number generators. Consider 3black balls and 7 red balls in a bin. The probability of choosing a black ball and a redball is is 0.3 and 0.7 respectively. A random number generator which generates anynumber between 0 and 1 (equally likely) can be used to choose a ball. We canassociate each possible random number generated to the input. If the numbergenerated is less than or equal to 0.3, then a black ball will be picked. For the numbersbetween 0.3 and 1, red ball will be selected.

Vamshi Randomized Algorithms 6of 26

Page 23: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 7of 26

Page 24: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 25: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice.

For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 26: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138.

Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 27: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice.

Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 28: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15.

How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 29: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy?

Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 30: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.

Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 31: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Consider two fair dice.Calculate the probability for particular sum of outcomes of thetwo dice. For example, the probability that the sum shows up 6 is 0.138. Roll the dicemanually 100 times and note down how many times the sum six turns up on the dice. Ifthe sum six showed up 15 times, the probability could be concluded as 0.15. How canyou increase accuracy? Accuracy increases with increase in number of times we rollthe dice.Monte Carlo method simulates rolling of dice for given number of times (say forinstance 1000 times) and gives the probability.

Vamshi Randomized Algorithms 8of 26

Page 32: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 33: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of π

Draw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 34: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it.

Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 35: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random.

What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 36: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle?

Ratio of area of circle to the area of square which is π4 . Ratio of number of

grains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 37: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square

which is π4 . Ratio of number of

grains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 38: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is

π4 . Ratio of number of

grains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 39: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 .

Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 40: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value.

Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 41: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 42: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 43: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 44: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 45: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimate the value of πDraw a square of 2× 2 units on floor and inscribe a circle in it. Scatter some objects ofsame size (such as grains) at random. What is the probability that the object falls insidethe circle? Ratio of area of circle to the area of square which is π

4 . Ratio of number ofgrains inside the circle to the total number of grains inside the square givesapproximately the same value. Multiplying with 4 gives the approximate value of π.

Note

To get the accurate value

(i) The number of objects should be large enough.

(ii) Each object has to be scattered uniformly at random. Object should not bedropped purposefully at a particular location inside the square.

Vamshi Randomized Algorithms 9of 26

Page 46: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 47: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo method

Let (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 48: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0).

Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 49: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.

Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 50: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{

1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 51: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,

0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 52: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 53: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 54: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 55: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Estimating π value using Monte Carlo methodLet (X ,Y ) be a point chosen uniformly at random in a 2× 2 square centered at origin(0, 0). Consider a circle of radius 1 unit centered at origin inscribed in the square.Consider a random variable Z such that

Z =

{1, if (X ,Y ) lies inside the circle,0, Otherwise.

Pr(Z = 1) =π

4

Assuming that the experiment is run m times with X and Y chosen independentlyamong the runs, let

W =m∑

i=1

Zi

E[W ] = E

[ m∑i=1

Zi

]=

m∑i=1

E[Zi ] =m · π

4

Vamshi Randomized Algorithms 10of 26

Page 56: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 57: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 58: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 59: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 60: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )

= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 61: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 62: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 63: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Examples

Example

Hence, W ′ = 4m ·W is an estimate of π.

Applying the following Chernoff bound,

Pr( |X − µ | ≥ δ · µ) ≤ 2 · e−µ·δ2/3

Pr( |W ′ − Π | ≥ ε · π) = Pr( |W − m·π|4 | ≥ ε·m·π

4 )= Pr( |W − E[W ] | ≥ ε · E[W ])

≤ 2 · e−m·Π·ε2/12

Therefore, m should be sufficiently large to obtain a tight approximation of π w.h.p.

Vamshi Randomized Algorithms 11of 26

Page 64: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 12of 26

Page 65: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 66: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 67: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 68: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 69: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?

As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 70: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1,

m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 71: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 72: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A randomized algorithm gives an (ε, δ)- approximation for the value V if the output X ofthe algorithm satisfies

Pr( |X − V | ≤ εV ) ≥ 1− δ

Question

In the π example, what should be the value of m for the algorithm to give an(ε, δ)-appromixation?As long as ε ≤ 1, m should be large enough to make

2 · e−m·π·ε2

12 ≤ δ

Solving the above equation, we get

m ≥12 · ln(2/δ)

π · ε2

Vamshi Randomized Algorithms 13of 26

Page 73: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Theorem

Let X1, ...,Xm be independent and identically distributed indicator random variables,with µ = E[Xi ]. If m ≥ 3·ln(2/δ)

ε2·µ , then

Pr

( ∣∣∣∣∣ 1m

m∑i=1

Xi − µ

∣∣∣∣∣ ≥ ε · µ)≤ δ

i.e, m samples provides an (ε, δ) approximation for µ.

Vamshi Randomized Algorithms 14of 26

Page 74: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Theorem

Let X1, ...,Xm be independent and identically distributed indicator random variables,

with µ = E[Xi ]. If m ≥ 3·ln(2/δ)

ε2·µ , then

Pr

( ∣∣∣∣∣ 1m

m∑i=1

Xi − µ

∣∣∣∣∣ ≥ ε · µ)≤ δ

i.e, m samples provides an (ε, δ) approximation for µ.

Vamshi Randomized Algorithms 14of 26

Page 75: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Theorem

Let X1, ...,Xm be independent and identically distributed indicator random variables,with µ = E[Xi ].

If m ≥ 3·ln(2/δ)

ε2·µ , then

Pr

( ∣∣∣∣∣ 1m

m∑i=1

Xi − µ

∣∣∣∣∣ ≥ ε · µ)≤ δ

i.e, m samples provides an (ε, δ) approximation for µ.

Vamshi Randomized Algorithms 14of 26

Page 76: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Theorem

Let X1, ...,Xm be independent and identically distributed indicator random variables,with µ = E[Xi ]. If m ≥ 3·ln(2/δ)

ε2·µ , then

Pr

( ∣∣∣∣∣ 1m

m∑i=1

Xi − µ

∣∣∣∣∣ ≥ ε · µ)≤ δ

i.e, m samples provides an (ε, δ) approximation for µ.

Vamshi Randomized Algorithms 14of 26

Page 77: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Theorem

Let X1, ...,Xm be independent and identically distributed indicator random variables,with µ = E[Xi ]. If m ≥ 3·ln(2/δ)

ε2·µ , then

Pr

( ∣∣∣∣∣ 1m

m∑i=1

Xi − µ

∣∣∣∣∣ ≥ ε · µ)≤ δ

i.e, m samples provides an (ε, δ) approximation for µ.

Vamshi Randomized Algorithms 14of 26

Page 78: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Theorem

Let X1, ...,Xm be independent and identically distributed indicator random variables,with µ = E[Xi ]. If m ≥ 3·ln(2/δ)

ε2·µ , then

Pr

( ∣∣∣∣∣ 1m

m∑i=1

Xi − µ

∣∣∣∣∣ ≥ ε · µ)≤ δ

i.e, m samples provides an (ε, δ) approximation for µ.

Vamshi Randomized Algorithms 14of 26

Page 79: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which, given an input x and any parameters ε and δ with0 < ε, δ < 1, the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in 1/ε, ln δ−1, and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 80: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which,

given an input x and any parameters ε and δ with0 < ε, δ < 1, the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in 1/ε, ln δ−1, and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 81: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which, given an input x and any parameters ε and δ with0 < ε, δ < 1,

the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in 1/ε, ln δ−1, and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 82: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which, given an input x and any parameters ε and δ with0 < ε, δ < 1, the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in

1/ε, ln δ−1, and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 83: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which, given an input x and any parameters ε and δ with0 < ε, δ < 1, the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in 1/ε,

ln δ−1, and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 84: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which, given an input x and any parameters ε and δ with0 < ε, δ < 1, the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in 1/ε, ln δ−1,

and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 85: Monte Carlo Method - West Virginia University

IntroductionApplications

Monte Carlo DefinitionExamplesDefinitions

Definitions

Definition

A fully polynomial randomized approximation scheme (FPRAS) for a problem is arandomized algorithm for which, given an input x and any parameters ε and δ with0 < ε, δ < 1, the algorithm outputs an (ε, δ)-approximation to V (x) in time that ispolynomial in 1/ε, ln δ−1, and the size of the input x .

Vamshi Randomized Algorithms 15of 26

Page 86: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 16of 26

Page 87: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 88: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.

Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 89: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 90: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 91: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 92: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 93: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Note

Sampling in Monte Carlo methods is not as simple as shown for estimating Π value.Sampling is often nontrivial.

What is a DNF?

A Boolean formula which comprises of disjuntion (OR) of clauses where each clause isa conjunction (AND) of literals.

Example

(x1 ∧ x̄2) ∨ (x3 ∧ x4) ∨ (x̄4 ∧ x1)

Vamshi Randomized Algorithms 17of 26

Page 94: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 95: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment?

An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 96: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 97: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?

False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 98: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False.

The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 99: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 100: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF?

Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 101: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using

De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 102: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 103: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment?

Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 104: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 105: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 106: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF

Questions

(i) What is a satisfying assignment? An assignment which when given to a Booleanformula returns TRUE.

(ii) Determining the satisfiability of CNF is simpler compared to DNF. True/False?False. The input assignment needs to satisfy just one clause in a DNF.

(iii) How to check the satisfiability of a CNF? Convert it into DNF using De Morgan’slaw.

(iv) If H is a CNF of n Boolean variables and H̄ is its DNF, what is the maximumnumber of satisfying assignments can H̄ have for H to have a satisfyingassignment? Strictly less than 2n.

Note

Counting the number of satisfying assignments for a DNF comes under#P − Complete Problems.

Vamshi Randomized Algorithms 18of 26

Page 107: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

Outline

1 IntroductionMonte Carlo DefinitionExamplesDefinitions

2 ApplicationsThe DNF Counting ProblemDNF Couting Algorithms

Vamshi Randomized Algorithms 19of 26

Page 108: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF Counting Algorithm

Input: A DNF formula F with n variables.Output: Y = an approximation of c(F ).

1: X ← 02: for (k = 1 to m) do3: Generate a random assignment for n variables, chosen uniformly at random from

all 2n possible assignments.4: if (the random assignment satisfies F ) then5: X ← X + 16: end if7: end for8: return Y ← ( X

m ) · 2n

Algorithm 3.1: DNF Counting Algorithm I: Naive approach

Vamshi Randomized Algorithms 20of 26

Page 109: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 110: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .

Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 111: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{

1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 112: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.

0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 113: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 114: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 115: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1?

c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 116: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 117: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 118: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 119: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

Notes

c(F )→ No. of satisfying assignments of DNF Formaula F .Let Xk be random variable such that

Xk =

{1, if k th iteration generates a satisfying assignment.0, Otherwise.

X =m∑

k=1

Xk .

What is the probability that Xk is 1? c(F )2n

E[Y ] =E[X ] · 2n

m= c(F )

Applying our previous theorem, Y gives an (ε, δ) -approximation of c(F ), when

m ≥3 · 2n · ln(2/δ)

ε2 · c(F )

Vamshi Randomized Algorithms 21of 26

Page 120: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Problems in Naive Approach

If c(F ) ≥ 2n/α(n) for some polynomial α, then we need number of samples mpolynomial in n, 1/ε, ln(1/δ).

However, c(F ) can be much less than 2n. In such case, it takes exponential number ofassignments before finding the first satisfying assignment.

The number of satisfying assignments might not be sufficiently dense enough in set ofall assignments.

To obtain FPRAS for this problem, we need to construct a better sample space thatincludes all the satisfying assignments of F and also, the satisfying assignments mustbe sufficiently dense in the sample space.

Vamshi Randomized Algorithms 22of 26

Page 121: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Problems in Naive Approach

If c(F ) ≥ 2n/α(n) for some polynomial α, then we need number of samples mpolynomial in n, 1/ε, ln(1/δ).

However, c(F ) can be much less than 2n. In such case, it takes exponential number ofassignments before finding the first satisfying assignment.

The number of satisfying assignments might not be sufficiently dense enough in set ofall assignments.

To obtain FPRAS for this problem, we need to construct a better sample space thatincludes all the satisfying assignments of F and also, the satisfying assignments mustbe sufficiently dense in the sample space.

Vamshi Randomized Algorithms 22of 26

Page 122: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Problems in Naive Approach

If c(F ) ≥ 2n/α(n) for some polynomial α, then we need number of samples mpolynomial in n, 1/ε, ln(1/δ).

However, c(F ) can be much less than 2n.

In such case, it takes exponential number ofassignments before finding the first satisfying assignment.

The number of satisfying assignments might not be sufficiently dense enough in set ofall assignments.

To obtain FPRAS for this problem, we need to construct a better sample space thatincludes all the satisfying assignments of F and also, the satisfying assignments mustbe sufficiently dense in the sample space.

Vamshi Randomized Algorithms 22of 26

Page 123: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Problems in Naive Approach

If c(F ) ≥ 2n/α(n) for some polynomial α, then we need number of samples mpolynomial in n, 1/ε, ln(1/δ).

However, c(F ) can be much less than 2n. In such case, it takes exponential number ofassignments before finding the first satisfying assignment.

The number of satisfying assignments might not be sufficiently dense enough in set ofall assignments.

To obtain FPRAS for this problem, we need to construct a better sample space thatincludes all the satisfying assignments of F and also, the satisfying assignments mustbe sufficiently dense in the sample space.

Vamshi Randomized Algorithms 22of 26

Page 124: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Problems in Naive Approach

If c(F ) ≥ 2n/α(n) for some polynomial α, then we need number of samples mpolynomial in n, 1/ε, ln(1/δ).

However, c(F ) can be much less than 2n. In such case, it takes exponential number ofassignments before finding the first satisfying assignment.

The number of satisfying assignments might not be sufficiently dense enough in set ofall assignments.

To obtain FPRAS for this problem, we need to construct a better sample space thatincludes all the satisfying assignments of F and also, the satisfying assignments mustbe sufficiently dense in the sample space.

Vamshi Randomized Algorithms 22of 26

Page 125: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Problems in Naive Approach

If c(F ) ≥ 2n/α(n) for some polynomial α, then we need number of samples mpolynomial in n, 1/ε, ln(1/δ).

However, c(F ) can be much less than 2n. In such case, it takes exponential number ofassignments before finding the first satisfying assignment.

The number of satisfying assignments might not be sufficiently dense enough in set ofall assignments.

To obtain FPRAS for this problem, we need to construct a better sample space thatincludes all the satisfying assignments of F and also, the satisfying assignments mustbe sufficiently dense in the sample space.

Vamshi Randomized Algorithms 22of 26

Page 126: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

FPRAS for DNF Couting

Let F = C1 ∨ C2 ∨ · · · ∨ Ct

A satisfying assignment needs to satisfy at least one clause.Let SCi be set of assignments that satisfy clause i

Let U = {(i, a) |1 ≤ i ≤ t & a ∈ SCi}

U denotes set of satisfying assignments for all clauses.

t∑i=1

|SCi | = |U |

Vamshi Randomized Algorithms 23of 26

Page 127: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

FPRAS for DNF Couting

Let F = C1 ∨ C2 ∨ · · · ∨ Ct

A satisfying assignment needs to satisfy at least one clause.Let SCi be set of assignments that satisfy clause i

Let U = {(i, a) |1 ≤ i ≤ t & a ∈ SCi}

U denotes set of satisfying assignments for all clauses.

t∑i=1

|SCi | = |U |

Vamshi Randomized Algorithms 23of 26

Page 128: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

FPRAS for DNF Couting

Let F = C1 ∨ C2 ∨ · · · ∨ Ct

A satisfying assignment needs to satisfy at least one clause.

Let SCi be set of assignments that satisfy clause i

Let U = {(i, a) |1 ≤ i ≤ t & a ∈ SCi}

U denotes set of satisfying assignments for all clauses.

t∑i=1

|SCi | = |U |

Vamshi Randomized Algorithms 23of 26

Page 129: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

FPRAS for DNF Couting

Let F = C1 ∨ C2 ∨ · · · ∨ Ct

A satisfying assignment needs to satisfy at least one clause.Let SCi be set of assignments that satisfy clause i

Let U = {(i, a) |1 ≤ i ≤ t & a ∈ SCi}

U denotes set of satisfying assignments for all clauses.

t∑i=1

|SCi | = |U |

Vamshi Randomized Algorithms 23of 26

Page 130: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

FPRAS for DNF Couting

Let F = C1 ∨ C2 ∨ · · · ∨ Ct

A satisfying assignment needs to satisfy at least one clause.Let SCi be set of assignments that satisfy clause i

Let U = {(i, a) |1 ≤ i ≤ t & a ∈ SCi}

U denotes set of satisfying assignments for all clauses.

t∑i=1

|SCi | = |U |

Vamshi Randomized Algorithms 23of 26

Page 131: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF- Counting Algorithm

FPRAS for DNF Couting

Let F = C1 ∨ C2 ∨ · · · ∨ Ct

A satisfying assignment needs to satisfy at least one clause.Let SCi be set of assignments that satisfy clause i

Let U = {(i, a) |1 ≤ i ≤ t & a ∈ SCi}

U denotes set of satisfying assignments for all clauses.

t∑i=1

|SCi | = |U |

Vamshi Randomized Algorithms 23of 26

Page 132: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 133: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣

c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 134: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U.

Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 135: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 136: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 137: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U?

First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 138: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 139: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

FPRAS for DNF Couting cont...

The count can be estimated by

c(F ) =

∣∣∣∣∣t⋃

i=1

SCi

∣∣∣∣∣c(F ) ≤ |U | , since an assignment can satisfy more than one clause and thus canappear in more than one pair in U. Let S be subset of U with size c(F ).

S = {(i, a) |1 ≤ i ≤ t , a ∈ SCi , a 6∈ SCj for j < i}

How to sample uniformly from U? First choose i from the pair (i, a) in U. Since i thclause has |SCi | satisfying assignments, we should choose i with probability

|SCi |∑ti=1 |SCi |

=|SCi ||U |

Vamshi Randomized Algorithms 24of 26

Page 140: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF-Counting Algorithm

Input: A DNF formula F with n variables.Output: Y = an approximation of c(F ).

1: X ← 02: for (k = 1 to m) do3: With probability |SCi |∑t

i=1 |SCi |choose, uniformly at random, an assignment a ∈ SCi .

4: if (a is not in any SCj , j < i) then5: X ← X + 16: end if7: end for8: return Y ← ( X

m ) ·∑t

i=1 |SCi |

Algorithm 3.2: DNF Counting Algorithm II: FPRAS

Vamshi Randomized Algorithms 25of 26

Page 141: Monte Carlo Method - West Virginia University

IntroductionApplications

The DNF Counting ProblemDNF Couting Algorithms

DNF Counting Algorithm

Theorem

DNF counting algorithm II is a fully polynomial randomized approximation scheme(FPRAS) for the DNF counting problem when

m = d(3 · t2/ε2) · ln(2/δ)e

Vamshi Randomized Algorithms 26of 26