# Python code and Summary of Monte Carlo Simulations

## Summary of Monte Carlo Simulations for Power Point

### Slide 1: Title

The Enigmatic Elegance of Monte Carlo Simulations: Unveiling the Secrets of Randomness in Complex Systems

### Slide 2: Introduction

• Monte Carlo simulation: powerful numerical technique
• Applicable in finance, physics, engineering, and more

### Slide 3: Historical Background

• Pioneered by Stanislaw Ulam, John von Neumann, and Nicholas Metropolis
• Developed while studying nuclear chain reactions

### Slide 4: Theoretical Foundations

• Law of Large Numbers: sample mean converges to population mean
• Random Number Generation: key to simulating stochastic systems

### Slide 5: Mechanics of the Method

1. Formulate a probabilistic model
2. Perform sampling and simulation
3. Analyze and interpret results

### Slide 6: Probabilistic Model

• Accurately reflects stochastic behavior of system
• Essential for successful simulation

### Slide 7: Sampling and Simulation

• Generate random samples based on probability distributions
• Simulate various possible outcomes

### Slide 8: Analysis and Interpretation

• Examine results for statistical data
• Determine mean, variance, and percentiles

### Slide 9: Applications

• Finance: option pricing, portfolio optimization, risk assessment
• Physics: radiation transport, statistical mechanics

### Slide 10: Conclusion

• Revolutionized understanding of randomness in complex systems
• Unlocks potential for new discoveries and insights

## Python Code of Monte Carlo Simulations

#### Here’s a simple example of a simulation in Python, estimating the value of pi:

```import random
import math

def monte_carlo_simulation_pi(num_points):
points_inside_circle = 0

for _ in range(num_points):
x = random.uniform(-1, 1)
y = random.uniform(-1, 1)
distance_from_origin = math.sqrt(x**2 + y**2)

if distance_from_origin &lt;= 1:
points_inside_circle += 1

pi_estimate = 4 * points_inside_circle / num_points
return pi_estimate

num_points = 1000000
pi_estimate = monte_carlo_simulation_pi(num_points)
print(f"Estimated value of pi using {num_points} points: {pi_estimate}")
```
``import randomimport mathdef monte_carlo_simulation_pi(num_points):    points_inside_circle = 0    for _ in range(num_points):        x = random.uniform(-1, 1)        y = random.uniform(-1, 1)        distance_from_origin = math.sqrt(x**2   y**2)        if distance_from_origin <= 1:            points_inside_circle  = 1    pi_estimate = 4 * points_inside_circle / num_points    return pi_estimatenum_points = 1000000pi_estimate = monte_carlo_simulation_pi(num_points)print(f"Estimated value of pi using {num_points} points: {pi_estimate}")``
a Monte Carlo simulation in Python, estimating the value of pi

## Reference

WIKIPEDIA: Monte Carlo Simulation