Skip to content

Standardise use of OffsetVectors #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

THargreaves
Copy link
Collaborator

This PR modifies all GeneralisedFilters/SSMProblems code to use use an OffsetArray for storing the xs and zs. Docstrings are updated to match.

This cleans up a few bits of the codebase and solves #49.

prev_x = t == 1 ? x0 : xs[t - 1]
prev_z = t == 1 ? z0 : zs[t - 1]
xs[t] = simulate(rng, model.outer_dyn, t, prev_x; kwargs...)
xs[t] = simulate(rng, model.outer_dyn, t, xs[t - 1]; kwargs...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be missing something, but why not something like this:

    xs = Vector{T_dyn}(undef, T)
    ys = Vector{T_obs}(undef, T)

    xs[1] = simulate(rng, model.dyn; kwargs...)
    for t in 1:T
        ys[t] = simulate(rng, model.obs, t, xs[t]; kwargs...)
        if t < T
            xs[t+1] = simulate(rng, model.dyn, t, xs[t]; kwargs...)
        end
    end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just how we've happened to define the SSMProblems interface. I recall that Hong was keen to have a separation between the initial state x0 and the other states that have associated observations.

Following from that convention, I feel that the offset vector is the cleanest way to achieve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants