def step(data, draw): # take one step through time # value of p in previous period pLag1 = fs.recall(data, "p", lag=1) eps = 0.0 # update all intermediate variables pNew = gbm(s0=pLag1, dt=1.0 / 12.0, mu=0.05, sig=0.10, eps=eps) cNew = max(0.0, pNew - 1.0) # return updated price history dataNew = fs.chron(data, {"p": pNew, "c": cNew}) return dataNew
def step(data, draw): # take one step through time # value of p in previous period pLag1 = fs.recall(data, "p", lag=1) # uniform draw --> standard normal draw u = next(draw) eps = stats.norm.ppf(u) # update all intermediate variables pNew = gbm(s0=pLag1, dt=1.0 / 12.0, mu=0.01, sig=0.10, eps=eps) cNew = max(0.0, pNew - 1.0) # return updated price history dataNew = fs.chron(data, {"p": pNew, "c": cNew}) return dataNew