A Guide to MATLAB for Beginners and Experienced Users

Monte Carlo Simulation

In order to make statistical predictions about the long-term results of a random process, it is often useful to do a simulation based on one's understanding of the underlying probabilities. This procedure is referred to as the Monte Carlo method.

As an example, consider a casino game in which a player bets against the house and the house wins 51% of the time. The question is: How many games have to be played before the house is reasonably sure of coming out ahead? This scenario is common enough that mathematicians long ago figured out very precisely what the statistics are, but here we want to illustrate how to get a good idea of what can happen in practice without having to absorb a lot of mathematics.

First we construct an expression that computes the net revenue to the house for a single game, based on a random number chosen between 0 and 1 by the MATLAB function rand. If the random number is less than or equal to 0.51, the house wins one betting unit, whereas if the number exceeds 0.51, the house loses one unit. (In a high-stakes game, each bet may be worth $1000 or more. Thus it is important for the casino to know how bad a losing streak it may have to weather to turn a profit so that it doesn't go bankrupt first!) Here is an expression that returns 1 if the output of rand is less than 0.51 and

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: FLASH Memory Chips
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.