python 中的随机微积分库

发布于 2024-08-07 15:45:32 字数 948 浏览 12 评论 0原文

我正在寻找一个Python库,它允许我计算随机微积分的东西,比如我定义扩散的随机过程的(条件)期望。我查看了 simpy (simpy.sourceforge.net),但它似乎不能满足我的需求。

这是为了快速原型设计和实验。 在java中,我成功地使用了(现在不活动)http://martingale.berlios.de/Martingale .html 库。

这个问题本身并不困难,但是有很多重要的、样板的事情要做(有效的内存使用、变量减少技术等等)。

理想情况下,我可以写这样的东西(只是说明性的):

def my_diffusion(t, dt, past_values, world, **kwargs):
    W1, W2 = world.correlated_brownians_pair(correlation=kwargs['rho'])
    X = past_values[-1]
    sigma_1 = kwargs['sigma1']
    sigma_2 = kwargs['sigma2']
    dX = kwargs['mu'] * X * dt + sigma_1 * W1 * X * math.sqrt(dt) + sigma_2 * W2 * X * X * math.sqrt(dt)
    return X + dX

X = RandomProcess(diffusion=my_diffusion, x0 = 1.0)
print X.expectancy(T=252, dt = 1./252., N_simul= 50000, world=World(random_generator='sobol'), sigma1 = 0.3, sigma2 = 0.01, rho=-0.1)

例如,除了在 numpy 中重新实现它之外,有人知道其他东西吗?

I am looking for a python library that would allow me to compute stochastic calculus stuff, like the (conditional) expectation of a random process I would define the diffusion. I had a look a at simpy (simpy.sourceforge.net), but it does not seem to cover my needs.

This is for quick prototyping and experimentation.
In java, I used with some success the (now inactive) http://martingale.berlios.de/Martingale.html library.

The problem is not difficult in itself, but there is a lot non trivial, boilerplate things to do (efficient memory use, variable reduction techniques, and so on).

Ideally, I would be able to write something like this (just illustrative):

def my_diffusion(t, dt, past_values, world, **kwargs):
    W1, W2 = world.correlated_brownians_pair(correlation=kwargs['rho'])
    X = past_values[-1]
    sigma_1 = kwargs['sigma1']
    sigma_2 = kwargs['sigma2']
    dX = kwargs['mu'] * X * dt + sigma_1 * W1 * X * math.sqrt(dt) + sigma_2 * W2 * X * X * math.sqrt(dt)
    return X + dX

X = RandomProcess(diffusion=my_diffusion, x0 = 1.0)
print X.expectancy(T=252, dt = 1./252., N_simul= 50000, world=World(random_generator='sobol'), sigma1 = 0.3, sigma2 = 0.01, rho=-0.1)

Does someone knows of something else than reimplementing it in numpy for example ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

离去的眼神 2024-08-14 15:45:32

你看过sage吗?

Have you looked at sage?

坏尐絯 2024-08-14 15:45:32

我在Python中见过的最接近这个的是 PyMC - 各种马尔可夫链蒙特的实现卡罗算法。

The closest I've seen to this in Python is PyMC - an implementation of various Markov Chain Monte Carlo algorithms.

幽梦紫曦~ 2024-08-14 15:45:32

我知道有人使用 日晷 来解决随机 ODE/PDE 问题,虽然我对这个库了解不够,无法确定它是否适合您的情况。 这里有 python 绑定

I know someone who uses Sundials to solve stochastic ODE/PDE problems, though I don't know enough about the library to be sure that it's appropriate in your case. There are python bindings for it here.

流绪微梦 2024-08-14 15:45:32

我正在研究一个随机过程(包括扩散过程和一些调节)python 库。请查看 Google 项目主页的此链接。干杯!

I'm working on a stochastic processes (including diffusion processes and some conditioning) python library. Check out this link to the google-project homepage. Cheers!

可可 2024-08-14 15:45:32

您可以使用 StochPy(Python 中的随机建模)

https://pypi.python.org/pypi/StochPy< /a>

You can use StochPy (Stochastic modeling in Python)

https://pypi.python.org/pypi/StochPy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文