Lesson 14 of 15
Monte Carlo Sampling
Monte Carlo Sampling
Monte Carlo simulation uses random sampling to model uncertainty. In quantitative finance, it is used to price derivatives, estimate risk (VaR), and simulate portfolio paths.
A key building block is generating samples from a normal distribution using the Box-Muller transform. Given two independent uniform samples :
Both and are independent standard normal samples. Scale to mean and std : .
This transform is efficient because each pair yields two normal samples.
Your Task
Implement:
mc_normal_samples(n, mu, sigma, seed)— generatennormal samples using Box-Muller andrandom.seed(seed)mc_mean(samples)— mean of a list of samples
Python runtime loading...
Loading...
Click "Run" to execute your code.