Skip to content

Latest commit

 

History

History
70 lines (61 loc) · 2.17 KB

File metadata and controls

70 lines (61 loc) · 2.17 KB

DiffusionDefinition

Stable Dev Build Status

Utility functions for defining diffusion processes in the fewest lines of code. The package is designed to work seamlessly with BridgeSDEInference.jl.

Minimal example

For instance, to define a Lorenz system it is enough to write

@diffusion_process Lorenz begin
    :dimensions
    process --> 3
    wiener --> 3

    :parameters
    _ --> (3, Float64)
    σ --> Float64

    :additional
    constdiff --> true
end

b(t, x, P::Lorenz) = @SVector [
    P.p1*(x[2]-x[1]),
    P.p2*x[1] - x[2] - x[1]*x[3],
    x[1]*x[2] - P.p3*x[3]
]

σ(t, x, P::Lorenz) = SDiagonal(P.σ, P.σ, P.σ)

It is also possible to include template parameters, for instance:

@diffusion_process Lorenz{T} begin
    :dimensions
    process --> 3
    wiener --> 3

    :parameters
    _ --> (3, T)
    σ --> Float64

    :additional
    constdiff --> true
end

We also provide some examples of pre-defined diffusion processes that can be imported without having to write any code with:

@load_diffusion :lorenz

To see a list of all pre-defined examples call

@load_diffusion

We additionally provide some functionality for sampling trajectories. For instance, to sample a three-dimensional standard Brownian motion use:

const DD = DiffusionDefinition
tt = collect(0.0:0.01:1.0)
wiener_path = rand(tt, Wiener(), zero(DD.ℝ{3}))

The wiener path can then be used in an Euler-Maruyama scheme to compute a trajectory under a given diffusion law:

XX = trajectory(tt, DD.ℝ{3})
P = Lorenz(28.0, 10.0, 8.0/3.0, 2.0)
DD.solve!(XX, wiener_path, P, zero(DD.ℝ{3}))

See the documentation for a comprehensive overview.