MonteCarlo
Monte Carlo Simulation to Estimate Pi
This program uses a Monte Carlo simulation to estimate the value of Pi. The program generates random points within a square of side length 2, centered at the origin, and calculates how many of those points fall inside a unit circle. The ratio of the points inside the circle to the total number of points is used to estimate Pi.
How to Run
- Make sure you have
numpyandmatplotlibinstalled, if not you can install them using the following command:pip install requirements.txt - Save the script as
pi.py. - Run the script using the command
python pi.pyorpy pi.pyif you have installed python from the microsoft store.
Output
The output is an animation of the Monte Carlo simulation and a GIF file named PI.gif saved in the same directory.
Portfolio Analysis with Real Stock Data
This program performs a Monte Carlo simulation to analyze the potential future returns of a portfolio composed of real stocks. Historical data is fetched from Yahoo Finance.
How to Run
- Make sure you have
numpy,pandas,matplotlib, andyfinanceinstalled, just as before if dont have them installed you can install them with the following command:
pip install requirements.txt
- Save the script as
portfolio.py. - Run the script using the command
python portfolio.pyorpy pi.pyif you have installed python from the microsoft store.
Output
The output is a histogram of the simulated portfolio returns and summary statistics such as mean return, standard deviation, and Value at Risk (VaR).