Experiment

Monte Carlo ln(2)

Estimate \(\ln(2)\) by averaging \(1/x\) samples drawn uniformly from \([1, 2]\).

Sampling \(x \in [1, 2]\) uniformly and averaging \(1/x\) approximates \(\int_{1}^{2} \frac{1}{x}\,dx = \ln(2)\). This experiment shows how quickly the Monte Carlo estimate converges.

Parameters: choose the number of samples to draw and optionally fix the RNG seed.

Parameters
Convergence
Summary

Samples: 500

Final estimate: 0.688486

True ln(2): 0.693147

Absolute error: 0.004661