Research Article

Monte Carlo Simulation for Estimating π: Algorithm Principle and Error Analysis

Jinhao Guo*
University of Toronto

* Corresponding author: [email protected]

Abstract

Monte Carlo simulation is a stochastic numerical method that approximates solutions to mathematical problems via repeated random sampling. Owing to its conceptual simplicity and broad applicability, it has become a foundational computational tool across physics, finance, engineering, and data science. This paper examines the algorithmic principle of Monte Carlo π estimation and systematically analyzes factors governing simulation accuracy. A Python-based numerical simulation is implemented: uniformly distributed random points are generated within a unit square, and the value of π is estimated by counting points falling inside the inscribed quarter circle. Experiments with varying sample sizes are conducted to assess their impacts on estimation accuracy and convergence behavior, and the influence of pseudo-random number generation on simulation outcomes is also discussed. The results confirm that estimation stability improves with increasing sample size, and the simulation error decays approximately at a rate proportional to the inverse square root of the sample size. This study elucidates the mathematical fundamentals underlying Monte Carlo simulation and offers an intuitive case for understanding the properties, strengths, and limitations of stochastic numerical methods. The findings deepen understanding of the relationship between sample size and simulation accuracy, and provide theoretical and practical support for extending Monte Carlo methods to more complex numerical simulation and uncertainty analysis tasks.

Keywords: Monte Carlo simulation; π estimation; Random sampling; Simulation error; Python
Published: September 8, 2026
DOI: 10.54254/2753-8818/2026.PU36482
Volume: TNS Vol.185
pp. 55-62
Download PDF

References

  1. Metropolis, N., & Ulam, S. (1949). The Monte Carlo method.Journal of the American Statistical Association, 44(247), 335–341.
  2. Hammersley, J. M., & Handscomb, D. C. (1964).Monte Carlo methods. Methuen.
  3. Fishman, G. S. (1996).Monte Carlo: Concepts, algorithms, and applications. Springer.
  4. Robert, C. P., & Casella, G. (2004).Monte Carlo statistical methods(2nd ed.). Springer.
  5. Owen, A. B. (2013).Monte Carlo theory, methods and examples. Stanford University.
  6. Kalos, M. H., & Whitlock, P. A. (2008).Monte Carlo methods(2nd ed.). Wiley.
  7. Kroese, D. P., Taimre, T., & Botev, Z. I. (2011).Handbook of Monte Carlo methods. Wiley.
  8. Rubinstein, R. Y., & Kroese, D. P. (2016).Simulation and the Monte Carlo method(3rd ed.). Wiley.
  9. Matsumoto, M., & Nishimura, T. (1998). Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator.ACM Transactions on Modeling and Computer Simulation, 8(1), 3–30.
  10. Niederreiter, H. (1992).Random number generation and quasi-Monte Carlo methods. Society for Industrial and Applied Mathematics.
  11. Caflisch, R. E. (1998). Monte Carlo and quasi-Monte Carlo methods.Acta Numerica, 7, 1–49.
  12. Lemieux, C. (2009).Monte Carlo and quasi-Monte Carlo sampling. Springer.