Skip to content

An implementation of the Monte Carlo method to estimate the area of an irregular figure inside a square

License

Notifications You must be signed in to change notification settings

FrancescoPaoloL/PolygonMonteCarloSimulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polygon MonteCarlo Simulation

Here we have an implementation of the Monte Carlo method to estimate the area of an irregular figure inside a square. The Monte Carlo method involves generating random points within the square and determining the proportion that fall inside the irregular figure.

To estimate the area of the irregular figure, use the following formula:

Estimated Area of Irregular Figure = (Number of Points Inside Irregular Figure / Total Number of Points Inside Square) × Area of Square

In practice we:

  • Generate many random points within a square that surrounds the shape.
  • Count how many points fall inside the irregular shape.
  • Estimate the area of the shape based on the ratio of points inside it compared to the total number of points.

example

Please note than in save_irregular_points.py we use the NPY format because it's faster compared to other formats. It's true that the benefits are minimal, but consider it a best practice.

Languages and Tools

Python

Requirements

matplotlib==3.6.3
numpy==1.24.2

Test Coverage

TODO

License

This project is licensed under the MIT License - see the LICENSE.md file for details


Connect with me

francescopaololezza francescopaololezza

About

An implementation of the Monte Carlo method to estimate the area of an irregular figure inside a square

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages