Index
DiffusionDefinition.AbstractBuffer
DiffusionDefinition.AbstractSDESolver
DiffusionDefinition.BoundedStateSpace
DiffusionDefinition.DiffusionProcess
DiffusionDefinition.DiffusionStateSpace
DiffusionDefinition.EulerMaruyama
DiffusionDefinition.LinearDiffBuffer
DiffusionDefinition.LinearDiffusion
DiffusionDefinition.LowerBoundedStateSpace
DiffusionDefinition.StandardEulerBuffer
DiffusionDefinition.UnboundedStateSpace
DiffusionDefinition.UpperBoundedStateSpace
DiffusionDefinition.Wiener
Base.Unicode.lowercase
Base.eltype
Base.rand
Base.zero
Base.zero
Base.zero
DiffusionDefinition.B
DiffusionDefinition.B!
DiffusionDefinition._bound_satisfied
DiffusionDefinition._bound_satisfied
DiffusionDefinition._bound_satisfied
DiffusionDefinition._bound_satisfied
DiffusionDefinition._is_datatype
DiffusionDefinition._symbol_in
DiffusionDefinition._symbol_in
DiffusionDefinition._symbol_in
DiffusionDefinition.a
DiffusionDefinition.a!
DiffusionDefinition.add_diff_function!
DiffusionDefinition.b
DiffusionDefinition.b!
DiffusionDefinition.clone
DiffusionDefinition.clone
DiffusionDefinition.const_parameter_names
DiffusionDefinition.const_parameter_names
DiffusionDefinition.const_parameter_names
DiffusionDefinition.const_parameters
DiffusionDefinition.const_parameters
DiffusionDefinition.constdiff
DiffusionDefinition.createstruct
DiffusionDefinition.default_type
DiffusionDefinition.default_type
DiffusionDefinition.default_wiener_type
DiffusionDefinition.default_wiener_type
DiffusionDefinition.diagonalBmat
DiffusionDefinition.diagonaldiff
DiffusionDefinition.dimension
DiffusionDefinition.end_point_info
DiffusionDefinition.end_point_info_names
DiffusionDefinition.fill_unspecified_with_defaults
DiffusionDefinition.fill_unspecified_with_defaults
DiffusionDefinition.fill_unspecified_with_defaults
DiffusionDefinition.get_curly
DiffusionDefinition.get_name_stem
DiffusionDefinition.grad_y1
DiffusionDefinition.grad_y1
DiffusionDefinition.grad_θ
DiffusionDefinition.grad_θ
DiffusionDefinition.highest_idx_used
DiffusionDefinition.hypo_a_inv
DiffusionDefinition.hypo_a_inv
DiffusionDefinition.ignore_for_cu
DiffusionDefinition.ignore_for_cu
DiffusionDefinition.nonhypo
DiffusionDefinition.nonhypo
DiffusionDefinition.nonhypo_σ
DiffusionDefinition.nonhypo_σ
DiffusionDefinition.nonhypo_σ
DiffusionDefinition.num_non_hypo
DiffusionDefinition.num_non_hypo
DiffusionDefinition.parameter_names
DiffusionDefinition.parameter_names
DiffusionDefinition.parameter_names
DiffusionDefinition.parameters
DiffusionDefinition.parameters
DiffusionDefinition.parse_line!
DiffusionDefinition.parse_line!
DiffusionDefinition.parse_line!
DiffusionDefinition.parse_line!
DiffusionDefinition.parse_lines!
DiffusionDefinition.parse_param_multi_names
DiffusionDefinition.parse_param_single_name
DiffusionDefinition.parse_process
DiffusionDefinition.phi
DiffusionDefinition.phi
DiffusionDefinition.prepare_abstract_type
DiffusionDefinition.process_name
DiffusionDefinition.remove_curly
DiffusionDefinition.set_parameters!
DiffusionDefinition.set_parameters!
DiffusionDefinition.solve!
DiffusionDefinition.solve!
DiffusionDefinition.sparseBmat
DiffusionDefinition.sparsediff
DiffusionDefinition.state_space
DiffusionDefinition.update_label
DiffusionDefinition.var_parameter_names
DiffusionDefinition.var_parameter_names
DiffusionDefinition.var_parameter_names
DiffusionDefinition.var_parameters
DiffusionDefinition.var_parameters
DiffusionDefinition.β
DiffusionDefinition.β!
DiffusionDefinition.σ
DiffusionDefinition.σ!
Random.rand!
Random.rand!
Random.rand!
Trajectories.trajectory
Trajectories.trajectory
DiffusionDefinition.@conjugate_gaussian
DiffusionDefinition.@conjugate_gaussian
DiffusionDefinition.@diffusion_process
DiffusionDefinition.@load_diffusion
DiffusionDefinition.@load_diffusion
DiffusionDefinition.Wiener
— Typestruct Wiener{D,Tdevice}
end
A struct defining the Wiener process. D
indicates the dimension of the process if it cannot be inferred from the DataType of the Trajectory. If the dimension can be inferred then it takes precedence over the value of D
.
Trajectories.trajectory
— MethodTrajectories.trajectory(tt, v::Type, D::Number)
Create a Trajectory with mutable states of dimension D
along the time collection tt
.
Trajectories.trajectory
— MethodTrajectories.trajectory(tt, v::Type)
Create a Trajectory with immutable states along the time collection tt
.
DiffusionDefinition.@conjugate_gaussian
— Macro@conjugate_gaussian DIFFUSION_NAME begin
BODY
end
Define helper functions for the conjugate gaussian updates of diffusion DIFFUSION_NAME. In BODY information can be passed as a list with elements of the form:
:entry-name --> entry-value
The following entry names have special meaning: :inplace
, :nonhypo
, :hypo_a_inv
. Any other name is interpreted as a parameter name for which function phi
is defined. More precisely, the following can be defined:
:inplace
:inplace --> true
to indicate that compmutations are to be done in-place. Otherwise, by default they are assumed to be done out-of-place.
:nonhypo
:nonhypo --> list-of-indices-with-non-degenerate-noise
e.g.
:nonhypo --> [1,3,5]
to indicate which coordinates have non-degenerate (i.e. non-zero) Wiener term Wiener term. It automatically defines num_non_hypo
for the user.
If no flag :inplace --> true
is passed, then it will be assumed that computations are done out-of-place by default and then no matter what subset you passed it will be internally saved as an SVector
so as to work as a static way of accessing a subset of parameters. Otherwise, no change will be made to list-of-indices-with-non-degenerate-noise
.
hypo_a_inv
:hypo_a_inv --> f(t,x,P)
where f
is a function that uses time variable t
, state variable x
and a struct with the target diffusion law P
.
phi
and ignore_for_cu
:name-of-parameter --> (φ₁(t,x,P), φ₂(t,x,P), ...)
where φ₁(t,x,P)
corresponds to all terms from the drift that are in the first non-degenerate coordinate and that are multiplied by the parameter with the name name-of-parameter
, etc. Any parameters of P
for which φ
is not defined will have a function ignore_for_cu
defined for them automatically and returning true
.
DiffusionDefinition.@diffusion_process
— Macrodiffusion_process(name, ex::Expr, p...)
Defines a diffusion process according to a template described in the documentation of the github repository: https://github.com/mmider/DiffusionDefinition.jl
DiffusionDefinition.@load_diffusion
— Macro@load_diffusion name
Loads the predefined diffusion process.
DiffusionDefinition.@load_diffusion
— Macro@load_diffusion
Displays available choices of predefined diffusion processes that can be loaded
DiffusionDefinition.AbstractSDESolver
— Typeabstract type AbstractSDESolver end
Supertype of flags indicating ODE solvers
DiffusionDefinition.DiffusionProcess
— TypeDiffusionProcess{T,DP,DW,SS,EI}
Types inheriting from DiffusionProcess
define Ito diffusions. T
denotes the datatype of each coordinate, DP
the dimension of the stochastic process, DW
the dimension of the Wiener process, SS
lists the state space restrictions
DiffusionDefinition.DiffusionStateSpace
— TypeDiffusionDomain
Types inheriting from DiffusionStateSpace
define the types of restrictions put on the state-space of the stochastic process.
DiffusionDefinition.EulerMaruyama
— Typestruct EulerMaruyama <: AbstractSDESolver end
Flag for indicating use of the Euler-Maruyama scheme for sampling diffusions. IMPORTANT: this is the only diffusion path sampler implemented in this package. There are no plans for implementing any other SDE solver in the forseeable future.
DiffusionDefinition.LinearDiffusion
— TypeLinearDiffusion{T,DP,DW,SS} <: DiffusionProcess{T,DP,DW,SS}
Types inheriting from LinearDiffusion
define a linear Ito-type diffusion, i.e. solutions to stochastic differential equations of the form: dXₜ = (BₜXₜ + βₜ)dt + σₜdWₜ, t∈[0,T], X₀=x₀.
Base.Unicode.lowercase
— MethodBase.lowercase(s::Symbol)
Lowercase all letters in a symbol
Base.rand
— FunctionBase.rand(w::Wiener, tt, y1)
Samples Wiener process on tt
, started from y1
and returns a new object with a sampled trajectory.
DiffusionDefinition.B
— FunctionB
Compute matrix B
of a linear diffusion out-of-place (should use StaticArrays).
DiffusionDefinition.B!
— FunctionB!
Compute matrix B
of a linear diffusion in-place (uses buffers to store temporary results).
DiffusionDefinition._bound_satisfied
— Methodbound_satisfied(::UnboundedStateSpace, x)
No restrictions, bounds satisfied by default
DiffusionDefinition._bound_satisfied
— Methodbound_satisfied(::LowerBoundedStateSpace{T,S,N}, x) where {T,S,N}
Checks if all coordinates adhere to lower bound restrictions
DiffusionDefinition._bound_satisfied
— Methodbound_satisfied(::UpperBoundedStateSpace{T,S,N}, x) where {T,S,N}
Checks if all coordinates adhere to upper bound restrictions
DiffusionDefinition._bound_satisfied
— Methodbound_satisfied(::BoundedStateSpace{L,U}, x) where {L,U}
Checks if all coordinates adhere to lower and upper bound restrictions
DiffusionDefinition._is_datatype
— Method_is_datatype(sym, p)
Utility function that checks whether sym
is a datatype. It returns true if sym
is either an in-built datatype (say float, StaticArray etc.) or if it is a template argument.
DiffusionDefinition._symbol_in
— Method_symbol_in(::Any, ::Any)
Return false
by default i.e. if the first argument is not a symbol nor its quote
DiffusionDefinition._symbol_in
— Method_symbol_in(s::QuoteNode, symbols)
Check if quote of a symbol s
is listed in a list of symbols symbols
DiffusionDefinition._symbol_in
— Method_symbol_in(s::Symbol, symbols)
Check if symbol s
is listed in a list of symbols symbols
DiffusionDefinition.a
— Functiona
Compute the diffusion function σσ' of a diffusion out-of-place (should use StaticArrays).
DiffusionDefinition.a!
— Functiona!
Compute the diffusion function σσ' of a diffusion in-place (uses buffers to store temporary results).
DiffusionDefinition.add_diff_function!
— Methodadd_diff_function!(fns, p)
Add a definition of a function consdiff
that indicates if the diffusion coefficient is constant
DiffusionDefinition.b
— Functionb
Compute the drift of a diffusion out-of-place (should use StaticArrays).
DiffusionDefinition.b!
— Functionb!
Compute the drift of a diffusion in-place (uses buffers to store temporary results).
DiffusionDefinition.clone
— Methodclone(P::T, θ::AbstractDict) where T <: DiffusionProcess
Simplified cloning of diffusion law P
. Substitute relevant parameters with new values. θ
must be a dict corresponding to parameters returned after a call to var_parameters
.
DiffusionDefinition.constdiff
— Functionconstdiff
Returns true if the diffusion coefficient does not depend on the state of the process or time.
DiffusionDefinition.createstruct
— Methodcreatestruct(abstract_type, name, params)
Create code that defines a struct defining a diffusion process.
DiffusionDefinition.fill_unspecified_with_defaults
— Methodfill_unspecified_with_defaults(p)
Fill all unspecified variables with default values
DiffusionDefinition.fill_unspecified_with_defaults
— Methodfill_unspecified_with_defaults(::Val{:additional}, p)
If unspecified, there are no restriction on a state space, the volatility coefficient is assumed constant, the diffusion is not linear and the datatype of each coordinate is set to Float64
.
DiffusionDefinition.fill_unspecified_with_defaults
— Methodfill_unspecified_with_defaults(::Val{:dimensions}, p)
If unspecified, the dimension of the stochastic process and the driving Brownian motion is set to 1.
DiffusionDefinition.get_curly
— Methodget_curly(::Type{K}) where K
Utility function that returns a tuple with all type-specifiers listed in the curly brackets.
Examples
julia> remove_curly(Array{Float64,1})
(:Float64, 1)
DiffusionDefinition.get_name_stem
— Methodget_name_stem(name_stem::Symbol, parameters)
Get the stem of a name for a parameters and then add a disambiguation index. Underscore _
used in place of name is defaulted to p
.
DiffusionDefinition.grad_y1
— Methodgrad_y1(y1, W, X, P, f)
Compute ∇f
with respect to the starting position y1
for a fixed Wiener path W
. X
is a container where the the trajectory computed for the Wiener path W
under the law P
will be stored.
DiffusionDefinition.grad_θ
— Methodgrad_θ(θ, y1, W, X, Law, f)
Compute ∇f
with respect to parameters θ
for a fixed Wiener path W
. X
is a container where the the trajectory computed for the Wiener path W
under the law Law
(θ
) will be stored. y1
is the starting position.
DiffusionDefinition.highest_idx_used
— Methodhighest_idx_used(name_stem, params)
Find the highest disambiguation index that has been used thus far for a given name_stem
.
DiffusionDefinition.hypo_a_inv
— Methodhypo_a_inv(t, x, P)
Similar to $a^{-1}:=(σσ^T)^{-1}$, with the only exception that all of the zero rows of $σ$ are first removed to yield $\hat{σ}$, and then, $(\hat{σ} \hat{σ}^T)^{-1}$ is computed.
DiffusionDefinition.ignore_for_cu
— Methodignore_for_cu(::Val{T}, P) where T
A flag to indicate that a parameter with name T
has no contribution to the computation of conjugate updates.
DiffusionDefinition.nonhypo
— Methodnonhypo(x, P)
Return the diffusion's coordinates that have direct contribution from some non-degenerate Wiener terms, i.e. leave out coordinates whose Wiener term is zero.
DiffusionDefinition.nonhypo_σ
— Methodnonhypo_σ(t::Float64, x, P)
Return a sub-matrix of the full volatility matrix σ
that consists of non-zero rows of σ
.
DiffusionDefinition.num_non_hypo
— Methodnum_non_hypo(Ptype::Type{T}) where T <: DiffusionProcess
Return a total number of coordinates of the diffusion process that have non-degenerate noise structure. I.e. it is equal to the total number of coordinates of the process minus the number of coordinates that have no direct Wiener contribution.
DiffusionDefinition.parse_line!
— Methodparse_line!(::Val{:additional}, line, p)
Parse a line that defines additional information about a diffusion process.
DiffusionDefinition.parse_line!
— Methodparse_line!(::Val{:aux_info}, line, p)
Parse a line that defines parameters of the diffusion. The line must be in a format: name –> parameter-description
DiffusionDefinition.parse_line!
— Methodparse_line!(::Val{:dimensions}, line, p)
Parse a line that defines the dimension of a diffusion process and the driving Brownian motion.
DiffusionDefinition.parse_line!
— Methodparse_line!(::Val{:parameters}, line, p)
Parse a line that defines parameters of the diffusion. The line must be in a format: name –> parameter-description
DiffusionDefinition.parse_lines!
— Methodparse_lines!(ex::Expr, p, condition)
Parse all lines of the expression ex
, but process only those which satisfy condition
. p
is a passed-around structure that accumulates processed information.
DiffusionDefinition.parse_param_multi_names
— Functionparse_param_multi_names(line, p)
Parse a line that defines parameters of the diffusion. The line must be in one of the formats: (pname1, pname2, ...) –> (numberofparameters, datatype) (pname1, pname2, ...) –> datatype (pname1, pname2, ...) –> (datatype1, datatype2, ...) In the former two cases defines number_of_parameters
-many parameters, with names p_name1
, p_name2
, ... and of datatype
type. In the last case the datatypes differ from parameter to parameter.
DiffusionDefinition.parse_param_single_name
— Functionparse_param_single_name(line, p)
Parse a line that defines parameters of the diffusion. The line must be in one of the formats: parametername –> (numberofparameters, datatype) parametername –> datatype In the former case defines number_of_parameters
-many parameters, with names parameter_name
i and of datatype
type. In the latter case defines a single parameters with name parameter_name
and of type datatype
.
DiffusionDefinition.parse_process
— Methodparse_process(name , ex::Expr, ::Any)
Parse a template defining a diffusion process, create a corresponding struct and specified functions, evaluate them in the environment of a package and then import the struct name to Main
scope, in which the package has been imported to.
DiffusionDefinition.phi
— Methodphi(::Val{T}, t, x, P) where T
If the drift can be written in a form:
for parameters $θ$ that are being updated, then phi
is a row of the matrix $φ(t,x)$ that get's multiplied by the coordinate of a θ vector with a name T
.
DiffusionDefinition.prepare_abstract_type
— Methodprepare_abstract_type(stem, dims, data_type, state_restr)
Create a string defining a parent, abstract type from its stem
, the dimensions dims
of the process and the driving Brownian motion, the datatype data_type
of each coordinate and the restrictions on the state space state_restr
.
DiffusionDefinition.process_name
— Functionprocess_name
Process the name of a struct by returning the pure name (without template arguments), the name with template arguments and a list of template arguments.
DiffusionDefinition.remove_curly
— Methodremove_curly(::Type{K}) where K
Utility function that removes all type-specifiers listed in the curly brackets.
Examples
julia> remove_curly(Array{Float64,1})
Array
DiffusionDefinition.set_parameters!
— Methodset_parameters!(P::DiffusionProcess, θ, entries)
Set parameters of a diffusion law P
in-place. entries
should be a collection of pairs Pair{Int64,Symbol} that list the relevant entries in θ
for reparameterization, together with the corresponding parameter names.
DiffusionDefinition.update_label
— Methodupdate_label(line, current_label)
Update the label, which signifies what type of information a given line in a template is supposed to be encoding.
DiffusionDefinition.β
— Functionβ
Compute vector β
of a linear diffusion out-of-place (should use StaticArrays).
DiffusionDefinition.β!
— Functionβ!
Compute vector β!
of a linear diffusion in-place (uses buffers to store temporary results).
DiffusionDefinition.σ
— Functionσ
Compute the volatility coefficient of a diffusion out-of-place (should use StaticArrays).
DiffusionDefinition.σ!
— Functionσ!
Compute the volatility coefficient of a diffusion in-place (uses buffers to store temporary results).
Random.rand!
— MethodRandom.rand!(
w::Wiener{D},
path::Trajectory{T,Vector{K}},
y1=zero(K,D,ismutable(K))
) where {T,K,D}
Samples Wiener process started from y1
and saves the data in path
. Uses a default random number generator.
Random.rand!
— MethodRandom.rand!(
rng::Random.AbstractRNG,
::Wiener{D},
path::Trajectory{T,Vector{Vector{K}}},
y1=zeros(K,D)
) where {K,T,D}
Samples Wiener process with mutable states, started from y1
and saves the data in path
. rng
is used as a random number generator.
Random.rand!
— MethodRandom.rand!(
rng::Random.AbstractRNG,
::Wiener,
path::Trajectory{T,Vector{K}},
y1=zero(K)
) where {T,K}
Samples Wiener process with immutable states, started from y1
and saves the data in path
. rng
is used as a random number generator.