Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 46 ยท Stochastic Models and Simulation

Chapter 7 overview: stochastic models and simulation

Meet stochastic models: random inputs, repeated simulation and summaries of the results, with a roadmap to Monte Carlo, random walks, Markov chains and queues.

Every model so far gave one answer for one set of inputs. Run it twice and you get the same curve. But the real world is not like that. Customers arrive at random times. A seed lands on good soil or bad. A tiny difference in who meets whom changes how an epidemic starts. When chance matters, a single run is just one possible story, and the honest answer is a distribution of outcomes: a typical value plus how widely the outcomes spread.

A die for random inputs, twelve random-walk paths for many simulated runs, and a histogram with a dashed mean line for the summary.
A stochastic model has random inputs. You run it many times and study the spread of results, not one run.

What you will learn

  • The difference between deterministic and stochastic models, and when randomness matters.
  • The three-step workflow: sample inputs, simulate, summarize.
  • How the chapter's four tools (Monte Carlo, random walks, Markov chains, queues) fit together.
  • Why averages alone can mislead.

Key terms

Stochastic model: a model that includes random quantities, so each run can give a different result.

Simulation: running a model on a computer, step by step, to see how it behaves.

Random sample: values drawn from a probability distribution.

Distribution of outcomes: the full set of results of many runs, with their frequencies.

When does chance matter?

Randomness matters most when numbers are small or when small differences get amplified. If a million people each flip a coin, almost exactly half show heads, and a deterministic model predicting 50 percent is excellent. If one new infection arrives in a village of 20 people, whether it takes off or fizzles out depends on luck in the first few days, and the smooth SIR curve of Chapter 5 is the wrong picture.

Chance also matters when the shape of the outcome is skewed. A project with three uncertain tasks takes longer on average than the sum of the most likely durations, because delays are bigger than speed-ups. A model that uses only the "typical" input can miss that completely. The statistician Sam Savage calls this the flaw of averages.

The workflow

  1. Choose distributions for the uncertain inputs (how long a task takes, how many customers arrive).
  2. Simulate the model many times, each time drawing fresh random inputs.
  3. Summarize the results: mean, spread, the chance of a bad outcome, a percentile.

Random inputs

Draw values From a distribution
Set a seed Make runs repeatable
1 / 4

What each lesson covers

  1. Monte Carlo methods: estimating ฯ€, risk in a project schedule and the birthday problem, with the 1/โˆšN error rule.
  2. Random walks and Markov chains: spread, gambler's ruin and long-run weather.
  3. Queue simulation: arrivals, service times, the load ฯ = ฮป/ฮผ and why waits explode near 1.
  4. Chapter review: summary poster, table and ten questions.

Try it

Two hundred random walkers each take 100 steps, forward or back with equal chance. No single path is predictable, but the group is.

Python Two hundred random walkers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a stochastic model?

    Stochastic means involving randomness.
  2. 2. Why is a smooth deterministic epidemic curve a poor model for one new case in a village of 20 people?

    With few individuals, chance events dominate, so the outcome is a distribution of possibilities.
  3. 3. What is the correct order for a simulation workflow?

    You define the random inputs, run the model many times and then study the results.
  4. 4. What does setting a random seed do?

    A seed starts the generator in a known state so you can reproduce a run.

Summary

  • Stochastic models include chance, so the answer is a distribution, not a number.
  • Workflow: choose input distributions, simulate many runs, summarize.
  • Averages can hide skew and risk; look at the spread and the tails.
  • Next: Monte Carlo, random walks, Markov chains and queues.

Next: Monte Carlo methods