本文是对Ito Formula的一个简单数字实验验证
假设
B
(
t
)
B(t)
B(t)是一个零初值的标准布朗运动,根据Ito Formula,有
∫
0
1
B
(
t
)
d
B
(
t
)
=
∫
0
1
d
{
1
2
B
(
t
)
2
−
1
2
t
}
=
1
2
⋅
B
(
1
)
2
−
1
2
\int_0^1B(t)dB(t)=\int_0^1d\left\{\frac{1}{2}B(t)^2-\frac{1}{2}t\right\}=\frac{1}{2}\cdot B(1)^2-\frac{1}{2}
∫01B(t)dB(t)=∫01d{21B(t)2−21t}=21⋅B(1)2−21
import numpy as np
import matplotlib.pyplot as plt
# 模拟布朗运动
def brownian_motion(T, N):
dt = T / N
t = np.linspace(0, T, N+1)
W = np.zeros(N+1)
np.random.seed(0)
W[1:] = np.cumsum(np.random.normal(0, np.sqrt(dt), N))
return t, W
# 计算积分,并绘图
def ito_integration(T, N):
t, W = brownian_motion(T, N)
plt.plot(t, W, c='#007fd4')
plt.xlabel('time')
plt.ylabel('position')
plt.show()
integral = np.sum(W[:-1] * np.diff(W))
ito_formula_result = 0.5 * (W[-1]**2 - T)
return integral, ito_formula_result
# 验证Ito Formula
T = 1
N = 10000
integral_value, ito_formula_result = ito_integration(T, N)
print("通过模拟计算得到的积分值为:", integral_value)
print("Ito Formula计算得到的值为:", ito_formula_result)
程序运行结果:
通过模拟计算得到的积分值为: 1.2112063056729379
Ito Formula计算得到的值为: 1.199010194366273