Skip to content

Instantly share code, notes, and snippets.

View Tejesh-Raut's full-sized avatar
🇮🇳

Tejesh Raut Tejesh-Raut

🇮🇳
View GitHub Profile
import matplotlib.pyplot as plt
cos_analytical_value = np.sin(2)
plt.plot([cos_analytical_value]*50)
plt.plot(mcos_estimates, '.')
plt.plot(cos_analytical_value + np.array(mcos_std)*3, 'r')
plt.plot(cos_analytical_value - np.array(mcos_std)*3, 'r')
plt.xlabel('Sample size')
plt.ylabel('Monte Carlo estimate')
@Tejesh-Raut
Tejesh-Raut / integration-monte-carlo.py
Last active September 28, 2020 19:13
Evaluate integral using Monte-Carlo simulation in Python
import numpy as np
from scipy.stats import uniform
np.random.seed(0)
mcos_estimates = [None]*50
mcos_std = [None]*50
for i in range(1,51):
unif_array = uniform.rvs(size = i*1000)*2