Closed THargreaves closed 1 month ago
A few things I wasn't sure about:
Do we use US or UK spellings for method names? (initialise or initialize?)
It doesn't really matter -- happy to keep UK spelling.
Is there a type stability issue with the definitions of methods for StateSpaceModel? Is using hasmethod an efficient way to check if a transition distribution is defined? Would a try-catch or cached value be better?
I'll leave these questions for @FredericWantiez to answer.
Good point. I'll just remove the PDMat
entirely. Seems overkill for what is meant to be an introductory example.
I'm a bit at a loss as to why the Kalman filter example doc page keeps failing:
ERROR: LoadError: LoadError: ParseError:
# Error @ /Users/tim/Particle Filtering/SSMProblems.jl/docs/src/examples/kalman-filter.md:10:52
x_filts = Vector{Vector{latent_type}}(undef, T)
P_filts = Vector{Matrix{latent_type}}(undef, T)
# └ ── Expected `end`
in expression starting at /Users/tim/Particle Filtering/SSMProblems.jl/docs/src/examples/kalman-filter.md:10
when executing the following code block from inputfile `~/Particle Filtering/SSMProblems.jl/examples/kalman-filter/script.jl`
```julia
function AbstractMCMC.sample(
model::LinearGaussianSSM,
::KalmanFilter,
observations::AbstractVector,
extras::AbstractVector,
)
T = length(observations)
latent_type = only(typeof(model.latent_dynamics).parameters)
x_filts = Vector{Vector{latent_type}}(undef, T)
P_filts = Vector{Matrix{latent_type}}(undef, T)
```
Does Literate.jl not allow blank lines in functions or am I missing something obvious?
Simplified the interface to only contain simulate
, logdensity
, distribution
. Docs and example updated. Think we're ready to merge now.
In the process I removed the SSM level versions of the old functions, since I realised they were largely redundant, and instead it makes more sense to define just a forward simulation method for each SSM type, which I've now added.
One thing to note is that the VSCode Julia extension doesn't play well with the function overloading and displays numerous "Possible method call error."s. I think this is more of a bug with the parser/linter and also occurred with the old-old interface, before splitting transition
into two functions.
An update to the SSMProblems.jl interface (changes to documentation and examples to come in a separate PR).
The key changes are as follows:
LatentDynamics
andObservationProcess
transition
andtransition_logdensity
(likewise for initialisation and observations)transition_logdensity
method has been change from containing "previous"/"current" state to "current"/"next" state to make it consistent withtransition
(motivated by the off-by-one error in the PGAS implementation)After discussing last week that we could pass
extras
in as a kwarg rather than as part of the conditional model, I realised that we could do the same withobservations
, makingConditionedStateSpaceModel
redundant, hence it is not included in this PR.A few features that I have not implemented in this PR yet in order to keep it simple:
AbstractParticleContainer
A few things I wasn't sure about:
StateSpaceModel
?hasmethod
an efficient way to check if a transition distribution is defined? Would a try-catch or cached value be better?