Monte Carlo simulation

Slides:



Advertisements
Similar presentations
Generating Random Numbers
Advertisements

1 Counting. 2 Situations where counting techniques are used  You toss a pair of dice in a casino game. You win if the numbers showing face up have a.
Mathematics in Today's World
Modeling and Simulation Monte carlo simulation 1 Arwa Ibrahim Ahmed Princess Nora University.
Lecture 11 – Stochastic Processes
CSCE 2100: Computing Foundations 1 Probability Theory Tamara Schneider Summer 2013.
Discrete Mathematical Structures (Counting Principles)
1.3 Simulations and Experimental Probability (Textbook Section 4.1)
M ONTE C ARLO SIMULATION Modeling and Simulation CS
Chapter 10 Introducing Probability BPS - 5th Ed. Chapter 101.
WOULD YOU PLAY THIS GAME? Roll a dice, and win $1000 dollars if you roll a 6.
1 1 Slide Simulation Professor Ahmadi. 2 2 Slide Simulation Chapter Outline n Computer Simulation n Simulation Modeling n Random Variables and Pseudo-Random.
Counting and Probability. Imagine tossing two coins and observing whether 0, 1, or 2 heads are obtained. Below are the results after 50 tosses Tossing.
AP Statistics From Randomness to Probability Chapter 14.
Chapter 11 Understanding Randomness. What is the most important aspect of randomness? It must be fair. How is this possible? 1) Nobody can guess the outcome.
Chapter 7. Section 7.1 Finite probability  In a lottery, players win a large prize when they pick four digits that match, in the correct order, four.
PROBABILITY AND STATISTICS WEEK 2 Onur Doğan. Introduction to Probability The Classical Interpretation of Probability The Frequency Interpretation of.
Basic Practice of Statistics - 3rd Edition Introducing Probability
Mathematics Department
Random Numbers and Simulation
ICS 253: Discrete Structures I
Linear Algebra Review.
From Randomness to Probability
Chapter 11 Probability.
Chapter 7: Counting Principles
Availability Availability - A(t)
Probability Imagine tossing two coins and observing whether 0, 1, or 2 heads are obtained. It would be natural to guess that each of these events occurs.
Chapter 6 6.1/6.2 Probability Probability is the branch of mathematics that describes the pattern of chance outcomes.
PROBABILITY AND PROBABILITY RULES
Chapter 3 Probability Larson/Farber 4th ed.
Using Simulation to Estimate Probabilities
Chapter 3 Probability.
CS104:Discrete Structures
Chapter 12 Tests with Qualitative Data
Conditional Probability
Section 5.1 Basic Ideas.
Understanding Randomness
From Randomness to Probability
AND.
Student Activity 1: Fair trials with two dice
Applicable Mathematics “Probability”
Discrete Probability Chapter 7 With Question/Answer Animations
Unit 6 Probability.
From Randomness to Probability
Elementary Statistics: Picturing The World
From Randomness to Probability
Understanding Randomness
PROBABILITY AND STATISTICS
Probability Probability underlies statistical inference - the drawing of conclusions from a sample of data. If samples are drawn at random, their characteristics.
Discrete Event Simulation - 4
Lecture 2 – Monte Carlo method in finance
Chapter 3 Probability.
Chapter 3 Probability Larson/Farber 4th ed.
Section 1 Sample Spaces, Events, and Probability
Honors Statistics From Randomness to Probability
Basic Practice of Statistics - 3rd Edition Introducing Probability
COUNTING AND PROBABILITY
Homework #5 — Monte Carlo Simulation
Lesson – Teacher Notes Standard:
Basic Practice of Statistics - 3rd Edition Introducing Probability
Counting Discrete Mathematics.
Probability using Simulations
From Randomness to Probability
Essential Statistics Introducing Probability
DETERMINANT MATH 80 - Linear Algebra.
Independence and Counting
Independence and Counting
Independence and Counting
Basic Practice of Statistics - 5th Edition Introducing Probability
Lecture 11 – Stochastic Processes
Presentation transcript:

Monte Carlo simulation Modeling and Simulation CS 313

EMPIRICAL PROBABILITY AND AXIOMATIC PROBABILITY The main characterization of Monte Carlo simulation system is being stochastic (random) and static (time is not significant). With Empirical Probability, we perform an experiment many times (n) and count the number of occurrences (na) of an event A The relative frequency of occurrence of event A is na/n. The frequency theory of probability asserts that the relative frequency converges as n →∞ Axiomatic Probability is a formal, set-theoretic approach, in which mathematically constructs the sample space and calculate the number of events A The two are complementary.

EXAMPLE Roll two dices and observe the up faces: If the two up faces are summed, an integer-valued random variable, say X, is defined with possible values 2 through 12 inclusive. Pr(X = 7) could be estimated by replicating the experiment many times and calculating the relative frequency of occurrence of 7’s

RANDOM VARIATES A Random Variate is an algorithmically generated realization of a random variable. u = Random() generates a Uniform(0, 1) random variate How can we generate a Uniform(a, b) variate? Generating a Uniform RandomVariate:

EQUILIKELY RANDOM VARIATES Uniform(0, 1) random variates can also be used to generate an Equilikely(a, b) random variate. Specifically, x = a + [(b − a + 1) u] Generating an Equilikely Random Variate:

EXAMPLES Example 1 To generate a random variate x that simulates rolling two fair dices and summing the resulting up faces, use: x = Equilikely(1, 6) + Equilikely(1, 6); Example 2 To select an element x at random from the array a[0], a[1], . . ., a[n − 1] use: i = Equilikely(0, n - 1); x = a[i]; Example 3 Galileo’s Dice: if three fair dices are rolled, which sum is more likely, a 9 or a 10? There are 63 = 216 possible outcomes

EXAMPLES This figure shows the slow convergence of relative frequency probability estimates for the three-dice random experiment. You should always run a Monte Carlo simulation with multiple initial seeds.

MC DRAWBACK The drawback of Monte Carlo simulation is that it only produces an estimate. Larger n does not guarantee a more accurate estimate.

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS Matrix: set of real or complex numbers in a rectangular array. For matrix A, aij is the element in row i, and column j Here, A is m × n (m rows, n columns) We consider just one particular quantity associated with a matrix: its determinant A single number associated with a square (nXn) matrix A, typically denoted as |A| or det A.

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS Random Matrices Matrix theory traditionally emphasizes matrices that consist of real or complex constants. But what if the elements of a matrix are random variables? Such matrices are referred to as “stochastic” or “random” matrices. Our question: if the elements of a 3 X 3 matrix are independent random numbers with positive diagonal elements and negative off-diagonal elements, what is the probability that the matrix has a positive determinant?

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS Specification Model Let event A be that the determinant is positive Generate N 3 × 3 matrices with random elements Compute the determinant for each matrix Let na = number of matrices with determinant > 0 Probability of interest: Pr(A) ≈ na/N

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS Computational Model

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS Output from det Want N sufficiently large for a good point estimate. Avoid recycling random number sequences Nine calls to Random() per 3 × 3 matrix  N . m / 9 ≈ 239 000 000 For initial seed 987654321 and N = 200 000 000, Pr(A) ≈ 0.05017347.

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 1: MATRICES AND DETERMINANTS Point Estimate Considerations How many significant digits should be reported? Solution: run the simulation multiple times One option: use different initial seeds for each run Caveat: Will the same sequences of random numbers appear? Another option: use different a for each run Caveat: use a that gives a good random sequence For two runs with a = 16807 and 41214 Pr(A) ≈ 0.0502

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 2: CRAPS The gambling game known as "Craps" provides a slightly more complicated Monte Carlo simulation application. The game involves tossing a pair of fair dices one or more times and observing the total number of spots showing on the up faces. If a 7 or 11 is tossed on the first roll, the player wins immediately. If a 2, 3, or 12 is tossed on the first roll, the player loses immediately. If any other number is tossed on the first roll, this number is called the "point". The dices are rolled repeatedly until the point is tossed (and the player wins) or a 7 is tossed (and the player loses).

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 2: CRAPS Toss a pair of fair dices and sum the up faces If 7 or 11, win immediately If 2, 3, or 12, lose immediately Otherwise, sum becomes “point” Roll until point is matched (win) or 7 (loss) What is Pr(A), the probability of winning at craps?

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 2: CRAPS Requires conditional probability Axiomatic solution: 244/495 ≈ 0.493 Underlying mathematics must be changed if assumptions change, e.g., unfair dice Axiomatic solution provides a nice consistency check for (easier) Monte Carlo simulation

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 2: CRAPS

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 2: CRAPS Craps: Computational Model Program craps: uses switch statement to determine rolls For N = 10 000 and three different initial seeds (see text), Pr(A) = 0.497, 0.485, and 0.502 These results are consistent with 0.493 axiomatic solution

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 3: HATCHECK GIRL A hatcheck girl at a fancy restaurant collects n hats and returns them at random. What is the probability that all of the hats will be returned to the wrong owner? Let A be that all checked hats are returned to wrong owners Let the checked hats be numbered 1, 2, . . . , n Girl selects (equally likely) one of the remaining hats to return  n! permutations, each with probability 1/n! E.g.: when n = 3 hats, possible return orders are 1,2,3 1,3,2 2,1,3 2,3,1 3,1,2 3,2,1 Only 2,3,1 and 3,1,2 correspond to all hats returned incorrectly  Pr(A) = 2/6 = 1/3

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 3: HATCHECK GIRL Specification Model Generate a random permutation of the first n integers The permutation corresponds to the order of hats returned One way to generate an element in a random permutation is to pick one of the n hats randomly, and return it to the customer if it has not already been returned. Generating a random permutation by this “obvious” algorithm is inefficient because: it spends a substantial amount of time checking to see if the hat has already been selected, and it may require several randomly generated hats in order to produce one that has not yet been returned.

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 3: HATCHECK GIRL Specification Model Generates a random permutation of an array a Check the permuted array to see if any element matches its index

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 3: HATCHECK GIRL Computational Model Program hat: Monte Carlo simulation of hatcheck problem Uses shuffling algorithm to generate random permutation of hats For n = 10 hats, 10 000 replications, and three different seeds. Pr(A) = 0.369, 0.369, and 0.368 A question of interest here is the behavior of this probability as n increases. Intuition might suggest that the probability goes to one in the limit as n  ∞, but this is not the case. One way to approach this problem is to simulate for increasing values of n and fashion a guess based on the results of multiple long simulations. One problem with this approach is that you can never be sure that n is large enough. For this problem, the axiomatic approach is a better and more elegant way to determine the behavior of this probability as n  ∞.

MONTE CARLO SIMULATION EXAMPLES EXAMPLE 3: HATCHECK GIRL Hatcheck: Axiomatic Solution The probability Pr(A) of no hat returned correctly is For n = 10, Pr(A) ≈ 0.36787946 Important consistency check for validating craps As n  ∞, the probability of no hat returned is 1/e = 0.36787944