Monte-Carlo Simulation with MCS-libre HOWTO
D. E. Williams
June 8, 2002
Contents
1 Introduction
2
2 Author
2
3 Monte-Carlo Simulation
2
3.1 Uses of Monte-Carlo Simulation . . . . . . . . . . . . . . . . .
2
3.2 Monte-Carlo Simulation with MCS-libre . . . . . . . . . . . .
3
4 Getting MCS-libre
3
5 Compiling and Linking with MCS-libre
3
6 Sampling From Statistical Distributions
4
6.1 Sampling from a Normal Distribution
. . . . . . . . . . . . .
4
6.2 Sampling from a Uniform Distribution . . . . . . . . . . . . .
5
6.3 Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
7 Collecting Statistics From Simulations
5
7.1 Declaring a Statistical Collection Object . . . . . . . . . . . .
5
7.2 Adding Values
. . . . . . . . . . . . . . . . . . . . . . . . . .
6
7.3 Retrieving Statistical Information . . . . . . . . . . . . . . . .
6
8 A Detailed Example Simulation
7
9 Precision and Error
9
9.1 Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
9.2 Operator Error . . . . . . . . . . . . . . . . . . . . . . . . . .
9
10 Improvements to MCS-libre Planned
9
1
1 Introduction
This document details how to perform Monte-Carlo simulation using the
MCS-libre toolkit for C++.
2 Author
D. E. Williams wrote both MCS-libre and this document. The author may
be contacted for any reason at
D. E. Williams
Attn: MCS-libre
720 NW 5th St. #54
Corvallis, OR 97330
UNITED STATES
or
williada@engr.orst.edu with the subject ”MCS-libre”.
Changes in these addresses will be noted in later releases of this docu-
ment.
3 Monte-Carlo Simulation
Monte-Carlo simulation is a sometimes elegant (and sometimes crude) method
for simulating complex systems. Parameters that affect the system are se-
lected from random distributions and the system response to these values is
then calculated. Repeating this process many times produces often useful
information about the system. The method is especially useful for examining
non-linear systems.
3.1 Uses of Monte-Carlo Simulation
Monte-Carlo simulation proves useful in the followin