This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |