# Perform scipy Kolmogorov-Smirnov Test for lognormal distribution in GBM

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?

• Very high or very low p-value? Please clarify? Commented May 4, 2017 at 11:36