PHAS0083 Chap.3 Monte Carlo Simulation and Density Estimates
Monte Carlo Simulation and Density Estimates
Monte Carlo Simulation and Density Estimates brings computation in early so that later theory can be checked against draws.
It explains that a computer produces pseudo-random numbers whose starting seed determines every later value, and that samplers for other distributions are built from uniforms either by the probability integral transform, which needs the inverse cdf, or by accept-reject sampling under an envelope, whose efficiency is the ratio of the two areas. A Q-Q plot checks a sampler against theoretical quantiles.
Models built from a chain of conditional steps are simulated down that chain of conditional distributions, drawing any latent variable before the variables that depend on it. The empirical cdf then turns draws into probabilities and quantiles; it is unbiased, has a binomial variance, and its relative precision improves only as the inverse square root of the number of draws, which fixes how many draws a target precision needs.
Histograms and kernel density estimates recover the shape of a pdf but depend on a bin width or bandwidth, so the notes use them for plotting and templates while computing every probability from the empirical cdf.
What this chapter covers
- 01
Pseudo-random numbers and seeds
- 02
Probability integral transform
- 03
Accept-reject sampling and efficiency
- 04
Simulating hierarchical models
- 05
The empirical cdf and quantiles
- 06
Number of draws for a target precision
- 07
Histograms and kernel density estimates
Worked example · free
Sample a power-law tail by inverting its cdf
- 1Integrate: F(x) = 1 - x⁻³ for x at least 1, which rises from 0 at x = 1 towards 1. This allocation is practice weighting, not a UCL marking scheme.
- 2Invert: u = 1 - x⁻³ gives x = 1/∛(1 - u).
- 1Substitute u = 0.875: x = (0.125)^(-1/3) = 2.
Key terms
- Envelope function
- A function lying above the target pdf everywhere, used to propose candidates in accept-reject sampling.
- Latent variable
- A random variable in a model that is never recorded, such as a true energy before detector smearing.
- Empirical cdf
- The step function giving the fraction of draws at or below each value.
- Kernel density estimate
- A smooth pdf estimate formed by averaging a kernel of chosen width centred on every draw.
Monte Carlo Simulation and Density Estimates FAQ
What makes a model hierarchical?
A model qualifies as hierarchical when it is built from conditional steps and at least one variable is latent, meaning it is part of the model but never recorded. A detector that records only smeared energies of photons with randomly shifted true energies is an example. If every variable in the chain is recorded, the chain alone does not make it hierarchical.
Why are computer random numbers called pseudo-random?
They come from a deterministic formula that maps one internal state to the next. Good generators leave no pattern that statistical checks can find and have very long periods, but the same seed always reproduces the same sequence, which is useful for checking results.
How many Monte Carlo draws do I need?
For a probability near p known to relative precision delta, the number of draws must be at least (1 - p) divided by p times delta squared. Small probabilities and tight precision are expensive: a tenfold gain in precision costs a hundredfold increase in draws.
Why not compute probabilities from a histogram?
A histogram depends on the chosen bin width and its counts are noisy, so different choices give different answers. The empirical cdf needs no choice and has a known variance, which is why the notes take probabilities, quantiles and thresholds from it.
Exam move
Practise the two sampling methods on paper first: invert three cdfs by hand, including one on an unbounded support, and compute the acceptance fraction of a box envelope for two pdfs with different peak heights. Then run a short script that draws from each sampler, plots a Q-Q plot and compares the empirical cdf with the true cdf, changing only the number of draws so you see the inverse-square-root shrinkage yourself.
For hierarchical models, write each conditional step as a line of the simulation in chain order and state which variables are latent. Learn the precision formula by deriving it from the binomial variance of a count, then apply it to a central probability and to a tail probability to feel the difference in cost.
Finish by comparing a histogram and a kernel estimate for two bin widths and two bandwidths, and write one sentence on why neither should be used to read a quantile.
Working through Monte Carlo Simulation and Density Estimates in PHAS0083? Sia is AskSia’s AI Statistics tutor — ask any PHAS0083 Monte Carlo Simulation and Density Estimates question and get a clear, step-by-step explanation grounded in how PHAS0083 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.