我是Python的新手,但对于大学的论文,我需要应用一些模型,最好使用Python.我花了几天时间使用我附带的代码,但是我无法提供帮助,这有什么不对,它不是创建一个随机过程,看起来像标准的布朗运动有漂移.我的参数如mu和sigma(预期回报或漂移和波动)往往只会改变噪声过程的斜率.这是我的问题,它看起来像噪音.希望我的问题足够具体,这是我的coode:
import math
from matplotlib.pyplot import *
from numpy import *
from numpy.random import standard_normal
'''
geometric brownian motion with drift!
Spezifikationen:
mu=drift factor [Annahme von Risikoneutralitaet]
sigma: volatility in %
T: time span
dt: lenght of steps
S0: Stock Price in t=0
W: Brownian Motion with Drift N[0,1]
'''
T=1
mu=0.025
sigma=0.1
S0=20
dt=0.01
Steps=round(T/dt)
t=(arange(0, Steps))
x=arange(0, Steps)
W=(standard_normal(size=Steps)+mu*t)### standard brownian motion###
X=(mu-0.5*sigma**2)*dt+(sigma*sqrt(dt)*W) ###geometric brownian motion####
y=S0*math.e**(X)
plot(t,y)
show()
Run Code Online (Sandbox Code Playgroud) 我的数据如下所示:
print data
A B
2014-04-04 163.24 191.77
2014-06-11 165.43 182.25
2014-12-22 194.44 161.44
2014-03-25 163.25 195.04
2014-11-03 190.83 164.36
2014-06-16 165.85 182.35
2014-11-24 190.07 162.15
2014-05-21 159.35 186.39
2015-01-21 177.15 152.09
2014-08-28 177.65 192.00
2014-02-19 163.26 182.95
2014-05-12 159.55 192.57
2014-07-09 164.67 188.42
2015-02-26 192.20 160.87
2014-10-14 178.70 183.80
2014-07-16 170.47 192.36
2014-01-21 173.20 188.43
2014-06-03 161.80 184.37
2014-03-17 166.84 185.81
2014-08-11 172.46 187.47
2015-01-07 187.28 155.05
2014-05-29 160.74 183.76
2015-02-11 187.65 158.20
2014-02-27 165.38 185.27
2015-01-05 188.34 159.51 …Run Code Online (Sandbox Code Playgroud)