神奇的Ito Formula

本文是对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)221t}=21B(1)221

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)

程序运行结果:
1s时间内布朗运动
通过模拟计算得到的积分值为: 1.2112063056729379
Ito Formula计算得到的值为: 1.199010194366273

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值