ObservationSchemes.jl

Base.eltypeMethod
eltype(::Type{K}) where {K<:Observation{D,T}}

Type of each entry of the collection holding an observation.

source
Base.lengthMethod
length(::Type{K}) where {K<:Observation{D}}

Length of the observation (equal to a number of entries in a vector holding the data)

source
Base.randFunction
Base.rand(G::StartingPtPrior, [z, ρ=0.0])

Sample a new starting point according to its prior distribution. An implementation with arguments z, ρ implements a preconditioned Crank-Nicolson scheme with memory parameter ρ and a current non-centered variable z. z is also referred to as the driving noise.

source
Base.randFunction
rand([rng::Random.AbstractRNG], G::GsnStartingPt, z, ρ=0.0)

Sample new white noise using Crank-Nicolson scheme with memory parameter ρ and a previous value of the white noise stored inside object G

source
Base.randMethod
rand([rng::Random.AbstractRNG], G::GsnStartingPt)

Sample new starting point according to its prior distribution.

source
Base.randMethod
rand([rng::Random.AbstractRNG], G::KnownStartingPt, args...)

Starting point is known. Nothing can be sampled. Returning known starting point.

source
Base.randMethod
Base.rand([rng::Random.AbstractRNG], o::LinearGsnObs, X)

Sample an observation according to

\[V ∼ L X + ξ,\quad \mbox{where } ξ∼N(μ,Σ),\]

with $L$, $μ$ and $Σ$ defined in o.

source
Base.sizeMethod
size(::Type{K}) where {K<:Observation{D}}

Size of the observation

source
Distributions.logpdfMethod
logpdf(G::GsnStartingPt, y)

log-probability density function evaluated at y of a prior distribution G

source
Distributions.logpdfMethod
logpdf(::KnownStartingPt, y)

Nothing to do so long as y is equal to the known starting point inside G

source
ObservationSchemes.LMethod
L(o::LinearGsnObs)

Return matrix L from the observation scheme ν = Lx+ξ, where ξ∼N(μ,Σ)

source
ObservationSchemes._prepare_xxMethod
_prepare_xx(::Val, os::ObsScheme, X)

Cycle through a collection X and transform it according to the observation schemes specified in os.

source
ObservationSchemes.add_dependency!Method
add_dependency!(all_obs::AllObservations, dep::Dict)

Add a dependency structure dep between parameters shared across various laws and observations used to generate various recordings stored in an observations container all_obs.

source
ObservationSchemes.add_recordings!Method
add_recordings!(
    all_obs::AllObservations,
    recordings::AbstractArray{<:NamedTuple}
)

Add multiple new recordings recordings to an observations container all_obs.

source
ObservationSchemes.build_recordingMethod
build_recording(
    ::Type{K}, tt, observs::Vector, P, t0, x0_prior; kwargs...
) where K

A utility function for building a recording. Times of recordings are assumed to be stored in tt and their values in observs. K is the type of observation (for instance LinearGsnObs). kwargs are name arguments that are passed to every single initializer of K.

source
ObservationSchemes.initializeMethod
initialize(all_obs::AllObservations)

Split the recordings at the times of full observations to make full use of the Markov property (and make the code readily parallelisable). Introduce all variable parameters that were not mentioned in the current dependency dictionary. Create internal dictionaries all_obs.param_depend_rev and all_obs.obs_depend_rev.

source
ObservationSchemes.inv_start_ptMethod
inv_start_pt(y, G::GsnStartingPt, P)

Compute the driving noise that is needed to obtain starting point y under prior G and the likelihood in P

source
ObservationSchemes.load_dataMethod
load_data(os::ObsScheme, tt, xx)

Decorate the data in xx and times of recordings in tt according to an observation scheme template stored in os.

source
ObservationSchemes.load_dataMethod
load_data(os::ObsScheme, tt_xx)

Same as load_data(os::ObsScheme, tt, xx), but tt_xx is a vector of tuples that pair the observations with their recorded times.

load_data(os::ObsScheme, tt_xx_filename::String)

Same as above, but tt_xx are stored in a .csv file named tt_xx_filename, with each row containing time t and its respective observation x stored back-to-back.

source
ObservationSchemes.local_symbolsMethod
local_symbols(
    all_obs::AllObservations,
    objects::AbstractArray{<:AbstractArray},
    f::Function,
    θsym::Vector{Symbol}
) where T

objects is usually an array of arrays that must in total have the same number of elements as there are observations in the recording. It may however have a different jagged structure. The output is of the same structure as objects and gives for each o in object a corresponding lists of parameters and observations it depends on.

source
ObservationSchemes.new_obs_dependence!Method
new_obs_dependence!(old_dep, old_to_new_idx)

Create a new interdependency dictionary for the observations from the old one old_dep and the dictionary old_to_new_idx that kept track of the changes.

Example

old_dep = Dict(
    :A => [(1, 2, 1), (1, 3, 2), (2, 1, 1)],
    :B => [(2, 2, 2), (3, 2, 1)],
)
old_to_new_idx = Dict(
    (1,1) => (1, 1), # obs (1,1) becomes (1,1)
    (1,2) => (1, 2),
    (1,3) => (2, 1), # obs (1,3) becomes (2,1)
    (2,1) => (3, 1),
    (2,2) => (4, 1),
    (2,3) => (5, 1),
    (3,1) => (6, 1),
    (3,2) => (6, 2),
)

new_dep = new_obs_dependence!(old_dep, old_to_new_idx)

new_dep == Dict(
    :A => [(1, 2, 1), (2, 1, 2), (3, 1, 1)],
    :B => [(4, 1, 2), (6, 2, 1)]
)
source
ObservationSchemes.new_param_and_obs_dependence!Method
new_param_and_obs_dependence!(
    out,
    old_p_dep,
    old_o_dep,
    old_to_new_idx,
    old_to_new_obs_idx
)

TODO refresh Define a new parameter dependence structure by using an old parameter dependence saved in old_dep and deducing the changed indices of affected recording by following the old_to_new_idx dictionary. The new dependency is saved directly to out structure.

source
ObservationSchemes.new_param_dependence!Method
new_param_dependence!(old_dep, old_to_new_idx)

Create a new interdependency dictionary for the parameters from the old one old_dep and the dictionary old_to_new_idx that kept track of the changes.

Examples

old_dep = Dict(
    :A => [(1, :a), (2, :a1)],
    :B => [(1, :b), (3, :bbb)],
)
old_to_new_idx = Dict(
    1 => [1, 2], # observation 1 was split into two
    2 => [3, 4, 5], # observation 2 was split into three
    3 => [6],
)

new_dep = new_param_dependence!(old_dep, old_to_new_idx)

new_dep == Dict(
    :A => [1=>:a, 2=>:a, 3=>:a1, 4=>:a1, 5=>:a1],
    :B => [1=>:b, 2=>:b, 6=>:bbb],
)
source
ObservationSchemes.print_parametersMethod
print_parameters(all_obs::AllObservations)

Print information about the variable parameters about which the all_obs.param_depend object stores some interdependency information.

source
ObservationSchemes.split_recording!Method
split_recording!(
        recording_idx,
        recording,
        counter,
        out::AllObservations,
        old_to_new_idx,
        old_to_new_obs_idx,
    )

Split a single record recording at the times of full observations. Save new, splitted recordings in the struct out. Keep account of the changed indices of the recordings for the recording index <---> parameter dependence pairs by updating a suitable dictionary old_to_new_idx, starting the new recording's index at an offset counter.

source
ObservationSchemes.start_ptMethod
start_pt(z, G::GsnStartingPt, P)

Compute a new starting point from the white noise for a given posterior distribution obtained from combining prior G and the likelihood encoded by the object P.

source
ObservationSchemes.ΛMethod
Λ(o::LinearGsnObs)

Return matrix Λ:=Σ⁻¹ from the observation scheme ν = Lx+ξ, where ξ∼N(μ,Σ)

source