Currently, the diffusion1d module provides a separate interface to diffusion that focuses on one dimensional processes.
The rationale for implementing a separate diffusion1d module are
Integration schemes (particularly Euler-Maruyama) can directly use operator *
instead of matrix multiplication @.
There are often specific integration methods or analytical solutions for 1D
processes.
On a the development-side of things, it is very often easier to implement a method
in the 1D case, before extending it to the n-D case.
However the module stochrare.dynamics.diffusion1d effectively greatly overlaps with
the more general stochrare.dynamics.diffusion.
For example, key methods trajectory and update do not depend on the dimension
of the process. Moreover, it is expected that as stochrare grows, both modules will
implement the same methods, with the exception of additional methods specific to the
1d case.
We could diffusion1d into the diffusion module, resulting in a single API
covering both 1D and n-D processes.
For example:
# New API
from stochrare.dynamics import diffusion
model = diffusion.ConstantDiffusionProcess(lambda x: 2*x, 1)
Should be equivalent to
# Old API
from stochrare.dynamics import diffusion1d
model = diffusion1d.ConstantDiffusionProcess1D(lambda x: 2*x, 1)
For this to work, we must
make sure integration schemes are implemented suitably dependending on the dimension
of the process. Example:
x = xn + self.drift(xn, tn)*dt + self.diffusion(xn, tn)*wn # 1d case
x = xn + self.drift(xn, tn)*dt+self.diffusion(xn, tn)@dw # n-d case
Prevent methods that are only relevant to the 1d case to be called if n>1
>>> from stochrare.dynamics import diffusion # Create 3D OU process
>>> model = diffusion.OrnsteinUlhenbeckProcess(0, 1, 1, 3)
>>> model.mean_first_passage_time(0, 5.0) # Try to evaluate mean first passage time
Traceback (most recent call last):
File "<diffusion.py>", line 3, in <stochare.dynamics.diffusion.mean_first_passage>
NotImplementedError: Mean first passage time is not available for processes of dimension higher than 1
Implement the above point is a way that makes initial development of 1d-only
method convenient.
Currently, the
diffusion1d
module provides a separate interface todiffusion
that focuses on one dimensional processes. The rationale for implementing a separatediffusion1d
module are*
instead of matrix multiplication@
.However the module
stochrare.dynamics.diffusion1d
effectively greatly overlaps with the more generalstochrare.dynamics.diffusion
. For example, key methodstrajectory
andupdate
do not depend on the dimension of the process. Moreover, it is expected that as stochrare grows, both modules will implement the same methods, with the exception of additional methods specific to the 1d case.We could
diffusion1d
into thediffusion
module, resulting in a single API covering both 1D and n-D processes.For example:
Should be equivalent to
For this to work, we must
This issues depends on