Practice question · Multiple choice
A Monte Carlo simulation run twice with different random seeds gives two different answers. Why is that a feature of a correct implementation rather than a bug?
Hints
- Ask what the estimate is computed from. Is the input the same on both runs?
- What would it mean if two runs with different seeds agreed to every digit?
Show the answer
A. Because the output is itself a random variable with a spread.
Why
The estimate is an average over randomly drawn samples, so it is itself a random variable with spread about σ/√N, the standard error the method predicts. That variation is diagnostic: rerunning and looking at the spread is the standard way to estimate uncertainty. Record the seed for reproducibility, rather than quoting eight digits from a method whose error is in the third.
Practise Vectorised Computation and Libraries
The app has 5 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.
More questions on Vectorised Computation and Libraries
- Monte Carlo error falls like 1/√(N) regardless of the dimension, which is why it wins in high dimensions.
- An interpreted loop processes 2 million elements per second while the vectorised version processes 500…
- Sort each code pattern by its style.
- Complete the reason vectorised code is faster.
- Monte Carlo error falls like 1/√N. To gain one more decimal digit of accuracy, what does that cost?