Skip to content

his project demonstrates the use of the Monte Carlo Simulation technique to estimate the value of Pi. By generating random points within a unit square and determining how many fall inside a unit circle, the algorithm leverages the principles of probability to estimate Pi.

License

Notifications You must be signed in to change notification settings

SudeErzurumlu/Monte-Carlo-Simulation-for-Estimating-Pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo Simulation for Estimating Pi

Overview

This project demonstrates the use of the Monte Carlo Simulation technique to estimate the value of Pi. By generating random points within a unit square and determining how many fall inside a unit circle, the algorithm leverages the principles of probability to estimate Pi.

This simulation is a great example of how computational methods can approximate complex mathematical constants in a simple yet effective manner.

Features

  • Multilingual Support: Includes implementations in Python, MATLAB, R, C#, Julia, and more.
  • Easy-to-understand: Clear and well-documented code that is accessible for both beginners and experienced developers.
  • Practical Use Case: A great way to understand the principles of Monte Carlo simulations and probability estimation.
  • Optimized for Performance: Implements efficient methods for random point generation and calculation of the proportion that lies inside the circle.

How It Works

The algorithm estimates Pi by randomly generating a large number of points within a unit square (with coordinates ranging from 0 to 1). The number of points that fall within the unit circle (radius = 1) is counted, and the ratio of points inside the circle to the total points generated is used to estimate Pi using the formula: The larger the number of points, the more accurate the estimation becomes.

Languages Used

This project contains implementations in the following languages:

  • Python
  • MATLAB
  • R
  • C#
  • Julia

Each implementation is self-contained and demonstrates the same Monte Carlo Pi estimation method in its respective language.

Installation & Usage

Python

To run the Python version of the simulation:

  1. Clone this repository:
    git clone https://github.com/SudeErzurumlu/Monte-Carlo-Simulation-for-Estimating-Pi
  2. Navigate to the Python folder:
    cd python
  3. Run the script:
    python monte_carlo_pi.py

MATLAB

To run the MATLAB version, open monte_carlo_pi.m and execute it within the MATLAB environment.

R

For R, run the monte_carlo_pi.R script after installing the necessary libraries.

C#

For the C# implementation, compile and execute the MonteCarloPiEstimation.cs file.

Julia

Run the monte_carlo_pi.jl script within the Julia environment.

Contributions

Feel free to fork the repository and submit pull requests to improve or extend the functionality. Contributions are always welcome.

License

This project is licensed under the MIT License.


Contact

For any questions or suggestions, feel free to open an issue on this repository.


About

his project demonstrates the use of the Monte Carlo Simulation technique to estimate the value of Pi. By generating random points within a unit square and determining how many fall inside a unit circle, the algorithm leverages the principles of probability to estimate Pi.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published