Python Code: Geometric Brownian Motion - what's wrong?

前端 未结 2 1806
执念已碎
执念已碎 2021-02-01 10:34

I\'m pretty new to Python, but for a paper in University I need to apply some models, using preferably Python. I spent a couple of days with the code I attached, but I can\'t re

2条回答
  •  情深已故
    2021-02-01 10:37

    An additional implementation using the parametrization of the gaussian law though the normal fonction (instead of standard_normal), a bit shorter.

    import numpy as np
    
    T = 2
    mu = 0.1
    sigma = 0.01
    S0 = 20
    dt = 0.01
    N = round(T/dt)
    # reversely you can specify N and then compute dt, which is more common in financial litterature
    
    X = np.random.normal(mu * dt, sigma* np.sqrt(dt), N)
    X = np.cumsum(X)
    S = S0 * np.exp(X)
    

提交回复
热议问题