def LogWalk(T, nSteps, mu, sigma, x_0=1, t_0=0, boundary=500): ex._check_params(T, nSteps, t_0) dt = T/(10*nSteps) x_t = [] t = t_0 for i in range((10*nSteps)): x = x_0*np.exp((mu - sigma**2/2)*t + sigma*np.random.randn()*np.sqrt(t)) if abs(x) > boundary: raise Warning("Risk of going beyond the definition of a random process. Boundary: " + str(boundary) + ". If You wish You could change boundary conditions in parameters (default:'boundary'=500).") x_t.append(x) t += dt
def OrnsteinUlenbekProcess(T, nSteps, alpha, beta, _sigma, x_0=1, t_0=0, boundary=500): ex._check_params(T, nSteps, t_0) dt = T/(10*nSteps) x_t = [] x_t.append(x_0) t = t_0 for i in range(1, 10*nSteps): x = alpha + (x_0 - alpha)*np.exp(-beta*t) + _sigma/np.sqrt(2*beta)*np.sqrt(1-np.exp(-2*beta*t))*np.random.randn() if abs(x) > boundary: raise Warning("Risk of going beyond the definition of a random process. Boundary: " + str(boundary) + ". If You wish You could change boundary conditions in parameters (default:'boundary'=500).") x_t.append(x) t += dt
def BrownianBridge(T, nSteps, alpha, _sigma, x_0=1, t_0=0, boundary=500): ex._check_params(T, nSteps, t_0) dt = T/(10*nSteps) x_t = [] x_t.append(x_0) t = t_0 for i in range(1, 10*nSteps): x = alpha + (x_0 - alpha)*(T - t)/(T - t_0) + _sigma*np.sqrt((t - t_0)*(T - t)/T - t_0)*np.random.randn() if abs(x) > boundary: raise Warning("Risk of going beyond the definition of a random process. Boundary: " + str(boundary) + ". If You wish You could change boundary conditions in parameters (default:'boundary'=500).") x_t.append(x) t += dt
def stoch_proc(T, nSteps, a, b, x_0=1, t_0=0, boundary=500): ex._check_params(T, nSteps, t_0) x_t = [] t = t_0 dt = T*/(10*nSteps) x = x_0 x_t.append(x_0) for i in range(1, 10*nSteps): t += dt x += a(x_t[i], t)*dt + b(x_t[i], t)*dW(dt) if abs(x) > boundary: raise Warning("Risk of going beyond the definition of a random process. Boundary: " + str(boundary) + ". If You wish You could change boundary conditions in parameters (default:'boundary'=500).") x_t.append(x)
def correlated_wandering(T, nSteps, ro, sigma, x_0, t_0=0): ex._check_params(T, nSteps, t_0)
def DampedOscillator(T, nSteps, sigma, lambda_, omega, x_0, y_0, t_0=0): ex._check_params(T, nSteps, t_0) x_t, y_t = [], []
def linear_system(T, nSteps, x_0, y_0, t_0=0): ex._check_params(T, nSteps, t_0)