A covariance estimate used in a risk report must identify its observations and divisor. A regression must identify its response and factors. This lesson connects NumPy calculations to those statistical objects, then checks a simulated option price against a closed form with a stated tolerance.
Learning objectives. By the end of this note you should be able to:
- compute sample means and covariances with an explicit
ddofchoice and state what was estimated; - fit a one-factor OLS slope (e.g. excess return on market) with a normal equation or
np.linalg.lstsq; - simulate a known model and assert the estimator or pricer lands near the closed form;
- refuse to invent econometric theory beyond what the computation requires.
In this lesson
- Sample mean and covariance
- Least squares as a linear map
- Simulation check against a known formula
- Portfolio variance as a quadratic form
- What this note deliberately skips
- Hand-off to design and delivery
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or browse the Python for Quantitative Finance syllabus.