Chapter 8. Simulation Examples
I provide five extensive examples of stochastic simulations in this chapter by building on and extending the material in Chapter 7. I will gradually make the examples more complicated, beginning with a simple coin toss problem and progressing to the hotel investment decision tree problem. More examples and explanations are in Paczkowski (2023).
The leading questions for this chapter are:
-
How do you specify a simulation?
-
How do you analyze a simulation’s results?
Example 1: Coin Toss
I discussed a simple coin toss experiment in Chapter 4 to introduce frequency-based probabilities. I simply noted that most people are familiar with the basic probability concept from tossing a coin. The assertion is that the probability of a heads-up on a toss of a fair coin is 0.50. I demonstrated where this number comes from in Chapter 4. But this does not mean it is correct in the real world. I also noted that probabilities are interpreted in terms of infinite series giving them a “long-run” interpretation. Of course, we cannot do something (e.g., flipping a coin) an infinite number of times. The question is then: “Can we devise an experiment to determine if, in the long-run (however defined), on the average, the probability is indeed 0.50?” You can do this with a simulation.
I provide a script in Figure 8-1 for simulating a coin toss. I first set some simulation parameters in Lines 4 to 11. A random seed is set at 42 followed by the number of coin tosses in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access