# Monte Carlo methods
Algorithm that uses repeated random sampling to approximate a numerical value that is hard to compute with exact methods. It might be that a formula is unavailable or impractical.
It is used to compute integrals, simulating complex systems such as physics and finance (that are described by differential equations which are can't be solved analytically), search and optimization by exploring large spaces. One disadvantage is that convergent can be slow.
Monte Carlo method can be used for area (which is the same as computing probability) approximation. For example computing $\pi$ using the fact the area of a quarter of a circle is equal to $\frac{\pi}{4}$ and so the probability to sample a point inside the area of the circle equals to the ratio of the quarter circle and unit square i.e., $\frac{\pi}{4}/1$ .
Uniformly sample $n$ points in the unit square which contains a quarter of a circle. check if the point is inside the circle or not by checking $x^2+y^2<1$. If you got $m$ points inside the circle then the $m/n\sim\frac{\pi}{4}$.
Monte Carlo method can be used for numerical approximation e.g., by computing $\pi$ via the formula $\frac{\pi}{4}=\int_0^1 \sqrt{1-x^2}$ . The integral on the right is the area under $y=\sqrt{1-x^2}$ of the qurter of the circle in $[0,1]$.
Uniformly sample $n$ point in the interval $[0,1]$ and compute $\sum_{i=0}^n \frac{1}{n}\sqrt{1-x_i^2}$ (where $\Delta_i=\frac{1}{n}$).
## Created 2026-04-24 14:07