We are going to compare a basic Monte Carlo Pandemic Simulation to the Projections of IHME, MIT, LOS ALAMOS, etc Pythonically.
Keep in mind I am an amateur at this 😉
Data Source https://ourworldindata.org/coronavirus
IHME http://www.healthdata.org/covid
Function Code: ( With the limited knowledge I have to build it)
def montecarlo(data):
global t_intervals
global iterations
global nostrodamus
global predict
log_returns = np.log(1 + data.pct_change())
u = log_returns.mean()
var = log_returns.var()
drift = u – (0.5 * var)
stdev = log_returns.std()
drift.values
stdev.values
t_intervals = len(data)
iterations = 10
nostrodamus = np.exp(drift.values + stdev.values * norm.ppf(np.random.rand(t_intervals, iterations)))
S0 = data.iloc[-1]
predict = np.zeros_like(nostrodamus)
predict[0] = S0
for t in range(1, t_intervals):
predict[t] = predict[t – 1] * nostrodamus[t]
return predict