Observations

The Observations object facilitates convenient storing, grouping and minibatching over observations.

The key objects

  1. The Observation is a container for an observed variables ("samples"), their noise covariances ("covariances"), and names ("names"). They are easily stackable to help build larger heterogenous observations
  2. The Minibatcher facilitate data streaming (minibatching), where a user can submit large group of observations, that are then batched up and looped over in epochs.
  3. The ObservationSeries contains the list of Observations and Minibatcher and the utilities to get the current batch etc.
I usually just pass in a vector of data and a covariance to EKP

Users can indeed set up an experiment with just one data sample and covariance matrix for the noise. However internally these are still stored as an ObservationSeries with a special minibatcher that does nothing (created by no_minibatcher(size)).

Here the user has data for two independent variables: the five-dimensional y and the eight-dimensional z. The observational noise of y is uncorrelated in all components, while the observations of z there is a known correlation.

We recommend users build an Observation using the Dict constructor and make use of the combine_observations() utility.

using EnsembleKalmanProcesses # for `Observation`
using LinearAlgebra # for `I`, `Tridiagonal`


# specify an observation of y with diagonal noise covariance
ydim = 5
y = ones(ydim)
cov_y = 0.01*I

# specify an observation of z with tridiagonal noise covariance
zdim = 8
z = zeros(zdim)
cov_z = Tridiagonal(0.1*ones(zdim-1), ones(zdim), 0.1*ones(zdim-1))

y_obs = Observation(
    Dict(
        "samples" => y,
        "covariances" => cov_y,
        "names" => "y",
    ),
)

z_obs = Observation(
    Dict(
        "samples" => z,
        "covariances" => cov_z,
        "names" => "z",
    ),
)

full_obs = combine_observations([y_obs,z_obs]) # conveniently stacks the observations
Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.0, 1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y", "z"], UnitRange{Int64}[1:5, 6:13])
# getting information out
get_obs(full_obs) # returns [y,z]
13-element Vector{Float64}:
 1.0
 1.0
 1.0
 1.0
 1.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
get_obs_noise_cov(full_obs) # returns block-diagonal matrix with blocks [cov_y 0; 0 cov_z]
13×13 Matrix{Float64}:
 0.01  0.0   0.0   0.0   0.0   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.01  0.0   0.0   0.0   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.01  0.0   0.0   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.01  0.0   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.01  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   1.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.1  1.0  0.1  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.1  1.0  0.1  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0  0.1  1.0  0.1  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0  0.0  0.1  1.0  0.1  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0  0.0  0.0  0.1  1.0  0.1  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0  0.0  0.0  0.0  0.1  1.0  0.1
 0.0   0.0   0.0   0.0   0.0   0.0  0.0  0.0  0.0  0.0  0.0  0.1  1.0

getters get_* can be used for all internals,

get_names(full_obs) # returns ["y", "z"]
2-element Vector{String}:
 "y"
 "z"

There are some other fields stored such as indices of the y and z components

get_indices(full_obs) # returns [1:ydim, ydim+1:ydim+zdim]
2-element Vector{UnitRange{Int64}}:
 1:5
 6:13

Imagine the user has 100 independent data samples for two independent variables above Rather than stacking all the data together at once (forming a full system of size 100*(8+5) to update at each step) instead the user wishes to stream the data and do updates with random batches of 5 observations at each iteration.

Why would I choose to minibatch?

The memory- and time-scaling of many EKP methods is worse-than-linear in the observation dimension, therefore there is often large computational benefit to minibatch EKP updates. Such costs must be weighed against the cost of additional forward map evaluations needed to minibatching over one full epoch.

# given a vector of 100 `Observation`s called hundred_full_obs,
using EnsembleKalmanProcesses # for `RandomFixedSizeMinibatcher`, `ObservationSeries`, `Minibatcher`

minibatcher = RandomFixedSizeMinibatcher(5) # batches the epoch of size 100, into batches of size 5

observation_series = ObservationSeries(
    Dict(
        "observations" => hundred_full_obs,
        "minibatcher" => minibatcher,
    ),
)
ObservationSeries{Vector{Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}}, RandomFixedSizeMinibatcher{String, Random.TaskLocalRNG, Vector{Vector{Int64}}}, Vector{String}, Vector{Vector{Vector{Int64}}}}(Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}[Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.094285486914397, 0.973120226099321, 1.103639824645526, 0.9304535470025941, 1.0438136155322764], [0.1782104218874819, 0.039512245669202944, -1.6362698722313316, -0.8399203408459872, -0.6299958637507828, -2.0876600242616137, 0.4681874044174793, -1.1917396487658454]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_1", "z_1"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9781135666226549, 0.9285516802236018, 0.978152205680951, 0.8641054967990954, 0.9352407054041169], [0.5339802631019057, -1.4110409293898984, 0.3586889229054725, 0.1333343653024691, -0.15341228446445548, -0.30352586209470417, 0.44572154804357333, -1.8233130709191332]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_2", "z_2"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9614085345395523, 1.0509268023962879, 0.9559867328124277, 0.8858910055711198, 1.047337807007483], [-1.6045156885304588, -0.4654615076762617, 0.5383580575779491, 0.014224689723968058, -0.8267600656405668, -0.3632671365919898, -0.6924186168654549, 0.261609790785692]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_3", "z_3"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.1460503315438475, 1.0438190422538192, 0.9057478074413159, 0.9861913494943348, 1.0913105266236585], [0.4974225386426625, -0.6185559421609429, 0.5684972924405236, 0.3246581563038564, -0.8874441353108345, 0.3767849234604428, -0.3654347933368399, -1.111203486219368]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_4", "z_4"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.920315115872459, 0.9677270089306067, 1.1396619899984533, 0.9914313063288654, 0.9521996269091672], [-1.59969308171467, 2.127987701959719, 0.7297255452446543, 0.05608884481181109, -0.4222089089045268, -0.4709612967372605, 0.2804798952834224, -0.4822263656188938]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_5", "z_5"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.0464595150012304, 0.9600793264304177, 1.172913923516475, 0.7391560846549601, 1.1447982405109443], [0.013820486292656602, -1.2020688092399827, 0.3043990019620969, -0.4923490471100971, 1.0924326965712379, 1.3808584102536852, -0.35633125533353355, 0.9844646511995505]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_6", "z_6"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9361990337859349, 1.133989615902042, 0.9712499656332709, 0.9885878362240238, 0.896256703325411], [1.2291158799890642, -1.5591192048373541, -0.961490320608176, 1.2950930807304435, -0.10022957602944899, -0.22209656997613575, -1.4336080559258413, -0.734376716706941]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_7", "z_7"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9595814657968734, 0.9695064743744577, 0.8915509941679596, 0.8976836796720287, 1.0220819556733913], [-0.3680728288268708, -1.3937036919228403, 0.1617060541683822, -0.4933821985524189, 1.0626885270107498, 0.8698461131758821, 1.067356798948081, 1.1506568954534766]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_8", "z_8"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.1447568120179115, 1.0514604725996584, 1.0559373361874185, 0.9014634827067021, 1.1352832019802912], [0.02210785932104953, -0.47584566356324876, -1.2894811855343828, -0.3015853510754447, -0.2485371571977031, -0.8038190459568018, -0.16025739740150372, 0.40550685385556673]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_9", "z_9"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.0308390009244337, 1.0935431028950156, 1.124636097629073, 1.0172832878967033, 0.9428624529476032], [-0.06392820011793851, -0.31865698384693375, 2.216804459850523, -0.300382336531765, -1.6233647491301562, 0.29579386951122955, -0.059347618468153916, 1.842119403539165]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_10", "z_10"], UnitRange{Int64}[1:5, 6:13])  …  Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.1893604198699572, 1.1679838398062805, 0.9880153362808883, 0.9985053348595215, 0.8297274990455431], [1.3085870461445173, -1.020988592830356, 0.5166615412417701, -0.7816507237918109, 0.41121255920391236, 0.254878638440778, 0.4534814213291136, 1.154453393529222]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_91", "z_91"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.8949380224024197, 0.8617668709481746, 1.0227288074239198, 1.2754562332392896, 0.8769534653687215], [-0.6923426087795836, 1.4852345502614144, 0.31569270909226094, -0.48789931726784697, 0.12506540911806197, -1.1544506923783626, -0.32870644085769263, -0.8830026289397537]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_92", "z_92"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.0594274950389624, 1.044785795291327, 0.9279953642703399, 1.0967162281998548, 0.9882202805904661], [0.5892346351755146, -0.668831344100308, -1.0892916074183947, -1.9297123398496, -0.8989176516833424, -1.9089842899490803, -0.8908760229381922, 1.0004706004179509]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_93", "z_93"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9653320422412568, 0.9373363619480715, 1.0908360879576737, 1.0606873169718918, 0.8978810075804454], [0.2700109306583176, -0.5057996486050305, -0.29891234136996814, -1.1721406667558312, 0.6593524769411375, 0.9885683804614154, -0.9185427356074881, -0.14913095421017436]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_94", "z_94"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9319053754051071, 0.8694920201555902, 1.0083953662833374, 0.9784206244281652, 0.9288123572120781], [1.2869907873171715, 0.0074219022744356905, -0.9759024783082418, 0.9258893943085417, 1.179675119223906, -0.37891518101911786, -1.6936275519320048, 1.6288579630340503]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_95", "z_95"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9781289909358064, 0.8917671634913134, 0.9108465685828082, 0.9268138743770624, 1.0071025858322393], [-0.30984299751190963, 0.08126312090982081, 0.49030054195507755, -1.2283552053300366, -1.9475801062998666, -0.152708062168933, -2.506535303125235, 0.8830021743704718]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_96", "z_96"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[1.033310514050847, 1.0081648512488657, 0.9744663871831052, 0.8418371251170191, 0.9591516266192078], [1.292577913235331, -0.01312564027176119, -0.4812598737240736, -0.6978655177589757, -1.0729637391486126, 1.7007433563170338, -0.7252742637244942, -0.7736973141358443]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_97", "z_97"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.9647894940637693, 0.718454247697161, 0.878902310895778, 1.0079219166105065, 0.8998027172931462], [1.7521586324494682, 0.9261898458508998, -0.3939425660509193, 0.3089866757494282, 0.5715672272062462, -0.8913606059367312, 1.6009660591445847, -1.3763912763575357]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_98", "z_98"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.8644375263752822, 0.9052589319703848, 0.9806503038436641, 1.041040368081465, 0.7369848684541267], [0.31936112468503874, -0.12325374023446799, 0.06410809136596282, -0.7380565268155418, -0.3345962291732923, -0.16845308452416471, -0.7409926938966557, -0.39299263291717634]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_99", "z_99"], UnitRange{Int64}[1:5, 6:13]), Observation{Vector{Vector{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{AbstractMatrix{Float64}}, Vector{String}, Vector{UnitRange{Int64}}}([[0.8434414127336579, 0.9876660269569281, 1.0832820542882826, 0.9634107451305998, 0.8963396863067171], [-0.21390978680350797, 1.9026213346550953, 2.055628257944421, -0.3766702392637697, 0.1211118123584119, 0.8962826014427456, -0.3864459492257699, -0.1387011960676481]], AbstractMatrix{Float64}[[0.01 0.0 … 0.0 0.0; 0.0 0.01 … 0.0 0.0; … ; 0.0 0.0 … 0.01 0.0; 0.0 0.0 … 0.0 0.01], [1.0 0.1 … 0.0 0.0; 0.1 1.0 … 0.0 0.0; … ; 0.0 0.0 … 1.0 0.1; 0.0 0.0 … 0.1 1.0]], AbstractMatrix{Float64}[[100.0 0.0 … 0.0 0.0; 0.0 100.0 … 0.0 0.0; … ; 0.0 0.0 … 100.0 0.0; 0.0 0.0 … 0.0 100.0], [1.010205144336438 -0.1020514433643792 … 1.0735488188434786e-6 -1.0735488188434786e-7; -0.10205144336437919 1.020514433643792 … -1.0735488188434786e-5 1.0735488188434786e-6; … ; 1.0735488188434788e-6 -1.0735488188434786e-5 … 1.020514433643792 -0.10205144336437919; -1.073548818843479e-7 1.0735488188434788e-6 … -0.10205144336437919 1.010205144336438]], ["y_100", "z_100"], UnitRange{Int64}[1:5, 6:13])], RandomFixedSizeMinibatcher{String, Random.TaskLocalRNG, Vector{Vector{Int64}}}(5, "extend", Random.TaskLocalRNG(), [[11, 45, 88, 26, 49], [83, 10, 16, 14, 52], [80, 59, 68, 67, 51], [27, 34, 48, 4, 78], [19, 15, 75, 61, 47], [1, 73, 36, 42, 35], [71, 87, 99, 65, 81], [43, 29, 86, 91, 92], [54, 24, 41, 30, 18], [76, 89, 84, 33, 9], [79, 12, 66, 5, 38], [8, 53, 50, 74, 98], [56, 6, 20, 46, 39], [57, 97, 100, 31, 77], [58, 60, 62, 82, 95], [7, 93, 64, 17, 28], [3, 70, 25, 55, 72], [96, 85, 22, 44, 23], [32, 37, 2, 40, 21], [94, 13, 69, 90, 63]]), ["series_1", "series_2", "series_3", "series_4", "series_5", "series_6", "series_7", "series_8", "series_9", "series_10"  …  "series_91", "series_92", "series_93", "series_94", "series_95", "series_96", "series_97", "series_98", "series_99", "series_100"], Dict("minibatch" => 1, "epoch" => 1), [[[11, 45, 88, 26, 49], [83, 10, 16, 14, 52], [80, 59, 68, 67, 51], [27, 34, 48, 4, 78], [19, 15, 75, 61, 47], [1, 73, 36, 42, 35], [71, 87, 99, 65, 81], [43, 29, 86, 91, 92], [54, 24, 41, 30, 18], [76, 89, 84, 33, 9], [79, 12, 66, 5, 38], [8, 53, 50, 74, 98], [56, 6, 20, 46, 39], [57, 97, 100, 31, 77], [58, 60, 62, 82, 95], [7, 93, 64, 17, 28], [3, 70, 25, 55, 72], [96, 85, 22, 44, 23], [32, 37, 2, 40, 21], [94, 13, 69, 90, 63]]])
# some example methods to get information out at the current minibatch:
get_current_minibatch(observation_series) # returns [i₁, ..., i₅],  the current minibatch subset of indices 1:100
5-element Vector{Int64}:
 11
 45
 88
 26
 49
get_obs(observation_series) # returns [yi₁, zi₁, ..., yi₅, zi₅], the data sample for the current minibatch
65-element Vector{Float64}:
  1.0434806808088049
  1.0078274844330097
  1.107482172144425
  1.0136004100131615
  1.0146258320892618
  0.9572842785598656
 -0.26473639411778904
  0.42942385570746283
 -0.8222833422778751
 -0.613642408485334
  ⋮
  0.8497983184251351
 -0.48846159341618045
 -0.20472108345218035
  0.498404687871263
  0.5923913307299931
  0.04567456899130885
 -0.5400600031743685
  0.3640533159923731
 -1.3323521640879838
get_obs_noise_cov(observation_series) # returns block-diagonal matrix with blocks [cov_yi₁  0 ... 0 ; 0 cov_zi₁ 0 ... 0; ... ; 0 ... 0 cov_yi₅ 0; 0 ... 0 cov_zi₅]
65×65 Matrix{Float64}:
 0.01  0.0   0.0   0.0   0.0   0.0  0.0  …  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.01  0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.01  0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.01  0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.01  0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   1.0  0.1  …  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.1  1.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.1     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 ⋮                             ⋮         ⋱            ⋮                   
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.1  0.0  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     1.0  0.1  0.0  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.1  1.0  0.1  0.0  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0  …  0.0  0.1  1.0  0.1  0.0  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.1  1.0  0.1  0.0  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.1  1.0  0.1  0.0
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.1  1.0  0.1
 0.0   0.0   0.0   0.0   0.0   0.0  0.0     0.0  0.0  0.0  0.0  0.0  0.1  1.0

minibatches are updated internally to the update_ensemble!(ekp,...) step via a call to

update_minibatch!(observation_series)
get_current_minibatch(observation_series)
5-element Vector{Int64}:
 83
 10
 16
 14
 52

Minibatchers

Minibatchers are modular and must be derived from the Minibatcher abstract type. They contain a method create_new_epoch!(minibatcher,args...;kwargs) that creates a sampling of an epoch of data. For example, if we have 100 data observations, the epoch is 1:100, and one possible minibatching is a random partitioning of 1:100 into a batch-size (e.g., 5) leading to 20 minibatches.

Some of the implemented Minibatchers

  • FixedMinibatcher(given_batches, "order"), (default method = "order"), minibatches are fixed and run through in order for all epochs
  • FixedMinibatcher(given_batches, "random"), minibatches are fixed, but are run through in a randomly chosen order in each epoch
  • no_minibatcher(size), creates a FixedMinibatcher with just one batch which is the epoch (effectively no minibatching)
  • RandomFixedSizeMinibatcher(minibatch_size, "trim"), (default method = "trim") creates minibatches of size minibatch_size by randomly sampling the epoch, if the minibatch size does not divide into the number of samples it will ignore the remainder (and thus preserving a constant batch size)
  • RandomFixedSizeMinibatcher(minibatch_size, "extend"), creates minibatches of size minibatch_size by randomly sampling the epoch, if the minibatch size does not divide into the number of samples it will include the remainder in the final batch (and thus will cover the entirety of the data, with a larger final batch)

Identifiers

One can additionally provide a vector of names to name each Observation in the ObservationSeries by giving using the Dict entry "names" => names.

To think about the differences between the identifiers for Observation and ObservationSeries consider an application of observing the average state of a dynamical system over 100 time windows. The time windows will be batched over during the calibration.

The compiled information is given in the object:

yz_observation_series::ObservationSeries

As this contains many time windows, setting the names of the ObservationSeries objects to index the time window is a sensible identifier, for example,

get_names(yz_observation_series)
> ["window_1", "window_2", ..., "window_100"]

The individual Observations should refer only to the state being measured, so suitable identifiers might be, for example,

obs = get_observations(yz_observation_series)[1] # get first observation in the series
get_names(obs)
> ["y_window_average", "z_window_average"]