Comments (2)
Thanks for the positive review!
So I wouldn't try to create two different BrownianInterval
s as you seem to be doing (self
, w1
). It's enough to create a single multidimensional BrownianInterval
, and then apply the appropriate correlation. For example:
class CorrelatedBrownianInterval(BrownianInterval):
def __init__(self, corr, **kwargs):
super().__init__(**kwargs)
self.corr = corr
def __call__(self, ta, tb):
dW = super().__call__(ta, tb)
# trick for computing batch matrix-vector product
# matrix `corr` has shape (channels, channels)
# batch of vectors `dW` has shape (batch, channels)
return dW @ self.corr.t()
rho = ...
corr = torch.tensor([[1, 0], [rho, (1 - rho.pow(2)).sqrt()]])
CorrelatedBrownianInterval(corr=corr, size=(batch_size, 2), ...)
I would however note that the SDE solvers are generally written assuming that you're using Brownian motion -- off the top of my head I'm not sure if some of the higher-order solvers like SRK will necessarily produce the right numerics given an arbitrary noise process. (The simpler ones like Euler will no doubt still be fine.)
The safer/more general option is to put any desired correlation into the diffusion matrix of the SDE you want to solve. That is, instead of having g(Y_t) (corr dW)
you have (g(Y_t) corr) dW
.
class SDE:
def __init__(self, corr, ...):
...
self.corr = corr
def _g(self, t, y):
...
def g(self, t, y):
return self._g(t, y) @ self.corr
And moreover the efficiency of this can be improved for most solvers by also providing
def g_prod(self, t, y, dW):
return self._g(t, y) @ (dW @ self.corr.t())
so that one evaluates a matrix-(matrix-vector) product rather than a (matrix-matrix)-vector product.
Does that answer your question?
(All code untested.)
from torchsde.
Yes, it does! I figured there was a better way to do it than creating two Brownian instances, and the more general form of adding the correlation directly to the diffusion makes a lot of sense. So I'll go with that approach. Thanks for your help, really great work!
from torchsde.
Related Issues (20)
- vector-valued SDE cumbersome workflow HOT 1
- Zero drift and zero diffusion matrices lead to non-zero changes of variable
- Irregular data and sampling posterior in latent_sde_lorenz.py
- Low CPU and GPU usage in training sde_gan, Seeking Help to Improve Performance. HOT 2
- Different `t` for data in a minibatch HOT 5
- torchsde pypi package is misformated HOT 26
- Deprecation torchsde version HOT 5
- Something went wrong Expecting value: line 1 column 1 (char 0) HOT 1
- Incorporating real stock time series data
- SDE-LSTM structure for time series forecasting
- Performance Improvement Inquiry: Experiencing Slow Execution with TorchSDE HOT 2
- Latent SDE failed to generate longer samples
- issue with my text to image ai Device type privateuseone is not supported for torch.Generator() api. HOT 1
- 我的 Mac上 只有torchsde-0.2.6.dist-info,怎样才能安装insightface
- 如果 torchsde 当前没有解决这个问题的新版本,你可以联系该项目的维护者或作者
- sdeint_adjoint for f_and_g_prod type SDE, how to set parameter?
- failure to install pip install qiskit-aer to run qsvm on ibm simulator
- learning the generative model of periodical process HOT 1
- extra_solver_state Documentation HOT 1
- WARNING: Error parsing dependencies of torchsde HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchsde.