def generate_gbm(lambda_0: float, T: int, paths: int = 1, mu: float = 0.5, sigma: float = 1, rng: np.random.Generator = rng): t = np.repeat(np.array([np.arange(1, T+1)]), paths, axis = 0) b = rng.normal(size=[paths, T]) w = b.cumsum(axis = 1) drift = (mu - 0.5 * sigma**2) * t diffusion = sigma * w S = lambda_0 * np.exp(drift + diffusion) return S
def generate_abm(lambda_0: float, T: int, paths: int = 1, mu: float = 0.5, sigma: float = 1, rng: np.random.Generator = rng): t = np.repeat(np.array([np.arange(1, T + 1)]), paths, axis=0) b = rng.normal(size=[paths, T]) w = b.cumsum(axis=1) S = lambda_0 + mu * t + sigma * w return S