Probability simulations and computations using Matlab

The first rule of programming is, never write a program from scratch! Start with an existing program that does something close to what you want to do, and modify it until it does what you want. In order for this to work, you have to have access to some model programs.

With that in mind, here are Matlab programs akin to the BASIC programs Grinstead and Snell discuss.

Chapter 1

Some simple probability experiments

ch1/prob.m

CoinTosses

ch1/cointosses.m

DeMere1 and DeMere2

ch1/demere1.m

ch1/demere2.m

HTSimulation

ch1/htsim.m

ch1/htahead.m

Section 1.1

Here are programs relating to some of the exercises in section 1.1. These exercises were formulated with an eye toward the BASIC programs that accompany the book. We'll ignore the specific instructions, which aren't always appropriate for Matlab, and heed what the problems are trying to get at.

Exercise 1: The strong law of large numbers

ch1/1.1/prob1.m

Exercise 2: The weak law of large numbers

ch1/1.1/prob2.m

Exercise 3: Rolling 9 versus 10 with three dice

ch1/1.1/prob3.m

Exercise 4: Racquetball

ch1/1.1/prob4.m

Exercise 5: Betting on triple-six with three dice

ch1/1.1/prob5.m

Exercise 10: Betting on roulette (no system)

ch1/1.1/prob10.m

Chapter 2

Monte Carlo evaluation of an integral

ch2/montecarlo.m

Bar graph for samples of a normal distribution

ch2/normaldensitybargraph.m

CDF of a normal random variable via simulation

ch2/normalcdf.m

Cantor's `Devil's Staircase' as a CDF

ch2/cantor.m

Throwing darts

ch2/dart.m

ch2/dartluck.m

ch2/dartsqrt.m



Peter G. Doyle 2012-03-27