{"id":25216668,"url":"https://github.com/santagatiivan/pi-estimation-using-monte-carlo-simulation","last_synced_at":"2025-04-05T09:16:15.751Z","repository":{"id":234774711,"uuid":"784692367","full_name":"santagatiivan/pi-estimation-using-monte-carlo-simulation","owner":"santagatiivan","description":"Estimate π using statistical simulation with random points in a circle-inscribed square. Dive into the math behind π!","archived":false,"fork":false,"pushed_at":"2024-04-26T16:14:48.000Z","size":70,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T19:39:23.753Z","etag":null,"topics":["monte-carlo-simulation","pi","pi-estimation","pi-estimator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santagatiivan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-10T11:12:46.000Z","updated_at":"2024-10-04T01:45:17.000Z","dependencies_parsed_at":"2024-04-26T17:34:11.379Z","dependency_job_id":null,"html_url":"https://github.com/santagatiivan/pi-estimation-using-monte-carlo-simulation","commit_stats":null,"previous_names":["santagatiivan/pi-estimation-using-monte-carlo-simulation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santagatiivan%2Fpi-estimation-using-monte-carlo-simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santagatiivan%2Fpi-estimation-using-monte-carlo-simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santagatiivan%2Fpi-estimation-using-monte-carlo-simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santagatiivan%2Fpi-estimation-using-monte-carlo-simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santagatiivan","download_url":"https://codeload.github.com/santagatiivan/pi-estimation-using-monte-carlo-simulation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312061,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monte-carlo-simulation","pi","pi-estimation","pi-estimator"],"created_at":"2025-02-10T19:31:14.509Z","updated_at":"2025-04-05T09:16:15.469Z","avatar_url":"https://github.com/santagatiivan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Estimating π using Monte Carlo Simulation\n\nThis project implements a Monte Carlo simulation to estimate the value of π. The simulation utilizes a statistical method based on randomly generating points within a square inscribed in a unit circle. By counting how many of these points fall inside the circle, we can estimate the area of the circle and thus the value of π.\n\n## Monte Carlo Method: Theory\n\nThe Monte Carlo method is a statistical technique that leverages random sampling to estimate numerical quantities. In the context of estimating π, the method operates as follows:\n\n1. **Generating Random Points:** We generate a large number of random points within a square of side length 2, centered at the origin.\n\n2. **Checking Point Locations:** For each generated point, we check whether it falls inside the unit circle inscribed in the square. We do this by calculating the Euclidean distance from the point to the origin. If this distance is less than or equal to 1, the point falls inside the circle.\n\n3. **Estimating π:** The probability that a randomly generated point falls inside the circle is proportional to the area of the circle relative to the total area of the square. We use this probability to estimate the value of π using the following formula:\n\n```\nπ ≈ 4 * (points inside circle) / (total points generated)\n```\n\n\nThe factor of 4 is included to account for the fact that the area of the square is 4 times the area of the inscribed circle.\n\n## System Requirements\n\n- Python 3.x\n- Tkinter (standard with Python installation)\n- Matplotlib (installable via `pip install matplotlib`)\n\n## Usage Guide\n\n### Installing Requirements\n\nEnsure you have Python 3 installed on your system. You can download it from the [official Python website](https://www.python.org/downloads/).\n\nInstall the `matplotlib` module by running the command:\n\n```bash\npip install matplotlib\n```\n\n### Running the Simulation\n\n- Download the repository and navigate to the directory containing the main.py file.\n- Run the main.py file with Python. You can do this via the terminal by executing the command:\n\n```bash\npython main.py\n```\nor\n```bash\npython3 main.py\n```\n\n### Using the User Interface\n\nOnce the simulation is launched, a Tkinter window will appear with the following controls:\n\n- **Speed**: Adjusts the speed of point generation.\n- **Marker Size**: Adjusts the size of the marker for generated points.\n- **Alpha**: Adjusts the opacity of the generated points.\n\n### Managing the Simulation\n\n- Click the \"Start\" button to begin the simulation. You can pause the simulation at any time by clicking \"Pause\" and resume it by clicking \"Start\" again.\n- You can also reset the simulation by clicking \"Reset.\"\n- Once the simulation is complete, you can save the results by clicking \"Save Results\". By doing so, you will be prompted to choose the name of the directory where the simulation data will be stored. The program will then automatically create the directory within the default downloads folder and save the results there.\n\n## Example Output\n\nHere's an example of output generated by the simulation:\n\n![view](img/MonteCarlo.PNG)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantagatiivan%2Fpi-estimation-using-monte-carlo-simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantagatiivan%2Fpi-estimation-using-monte-carlo-simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantagatiivan%2Fpi-estimation-using-monte-carlo-simulation/lists"}