Math for Machine Learning
A simulation-first approach
Preface

Welcome to Math for Machine Learning — a simulation-first guide to the mathematics behind modern ML.
Most math books teach a concept by first defining it formally, then proving things about it, and finally — if there’s room — showing an example. This book inverts that. Every concept is introduced as a problem you can simulate, watch unfold, and reason about visually before the formula appears. The proofs and rigorous derivations are all here, but they live behind collapsible ▶ Show the math boxes that you open only when you want them.
The structure of every section is the same:
- Story — a concrete problem you can imagine.
- Simulation — Python code you can run that exposes the pattern.
- Picture / table — what the data shows.
- Formula — the math, revealed as a description of what you just saw.
- ▶ Show the math — the rigorous version, on demand.
This is a living document. New chapters are added as they are written. The Edit this page link in the top-right of each chapter goes straight to the source on GitHub.
This is an early build. Currently available: the introduction and the probability core (What is Probability?, Conditional Probability). More chapters are added as they’re written.