Jan. 13, 2022, 9:04 p.m. | Andrea Gustafsen

Towards Data Science - Medium towardsdatascience.com

How to simulate pi with only a few lines of code.

Photo by Taso Katsionis on Unsplash

A common example to illustrate how Monte Carlo simulation can be used is by estimating pi. This article will show you how to do this simulation with only a few lines of code using R. Before writing our code, let us go through the mathematical formula we will use to estimate pi.

Image by Author

Find an expression for pi

Pi is a …

data science ggplot2 monte-carlo pi simulation

Data Scientist (m/f/x/d)

@ Symanto Research GmbH & Co. KG | Spain, Germany

Enterprise Data Architect

@ Pathward | Remote

Diagnostic Imaging Information Systems (DIIS) Technologist

@ Nova Scotia Health Authority | Halifax, NS, CA, B3K 6R8

Intern Data Scientist - Residual Value Risk Management (f/m/d)

@ BMW Group | Munich, DE

Analytics Engineering Manager

@ PlayStation Global | United Kingdom, London

Junior Insight Analyst (PR&Comms)

@ Signal AI | Lisbon, Lisbon, Portugal