I am simulating asset prices for n days using GMB with Euler scheme, calculate returns and then perform Kolmogorov-Smirnov test on simulated returns. Code for simulating GBM :

def simulate_GBM(mu, sig, asset_price, number_of_days):

        delta = 1 / 252
        t = np.arange(0, number_of_days / 252, delta)

        path = np.zeros(len(t))

        path[0] = asset_price

        for i in range(0, len(t) - 1):
            path[i + 1] = path[i] + path[i] * mu * delta + \
                          sig * path[i] * sqrt(delta) * np.random.randn()
            if path[i + 1] < 0:
                print("Zero assset values!")
                path[i + 1] = 1
        return path

Code for Monte-Carlo GBM

def perform_GBM_Monte_Carlo(mu, sig, asset_price, num_sim, number_of_days):

        simulations = np.zeros(num_sim)
        stop_date = number_of_days

        for i in range(0, self.num_sim - 1):
            simulations[i] = (simulate_GBM(mu, sig, asset_price, num_sim, number_of_days)[stop_date - 1])

        return simulations

Then I calculate returns and perform test

data = perform_GBM_Monte_Carlo(0.05, 0.3, 100, 100000, 252)
returns = np.zeros(len(data))
for i in range(0, len(data) - 1):
    returns[i] = data[i]/100 - 1 # initial asset price is 100

lognorm_params = stats.maxwell.fit(returns)
t_stat, p = stats.kstest(returns, 'lognorm', lognorm_params)

Theory says that returns must be lognormally distributed, but I have very p_value. Is the problem with GBM simulation or the way I perform K-S test?

  • $\begingroup$ Very high or very low p-value? Please clarify? $\endgroup$ – SmallChess May 4 '17 at 11:36

I haven't checked your code, but ... even if your code is all correct (you have calculated the lognormal returns), your test won't work.

You have 100000 samples, this is a large number. With this large sample size (and huge statistical power), the KS-test will reject anything. If you don't believe me, try to draw 100000 lognormal distribution directly from Python, your KS-test will still reject you for very low p-value.

Statistical test is meaningless for a large sample size, unless you want very low level of significance.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.