Closed marcoct closed 5 years ago
Hi @marcoct, thanks for getting in touch. You need to replace the following line
hiddens = Vector{Int}(undef, num_steps)
with
hiddens = TArray{Int}(undef, num_steps)
The reason why TArray
is required is explained in
Libtask
README file Here is the updated result with the correct code:
Great, thank you @yebai!
Can this be closed?
It might be desirable to throw an error if a regular Array
is used in a place where a TArray
should be used.
Good idea! Could you open a new issue for that? Thanks!
It might be desirable to throw an error if a regular Array is used in a place where a TArray should be used.
I have been thinking about automating promotion of Array
to TArray
but have not got a good idea yet. Any suggestion? @marcoct
I found discrepancies between the log marginal likelihood (log evidence) estimates obtained using Turing's implementation of a particle filter, and the log marginal likelihood estimates obtained using different techniques, including (i) a hand-coded particle filter, and (ii) particle filters implemented with Gen.
To highlight the discrepancy, I made a minimal example that estimates the marginal likelihood of a short sequence of observations in a small discrete HMM, for which the log marginal likelihood can be computed deterministically using the forward algorithm, I compared these values to values computed using Turing, and to values obtained using a handcoded implementation of a particle filter for the HMM. The results from this experiment are shown here (the x-axis is the number of particles in the particle filters, and the y-axis is the average of log marginal likelihood estimates obtained from 100 independent runs of each particle filter):
Note that the intent is that the handcoded particle filter and the Turing particle filter should be implementing the same algorithm.
For completeness, I am including code for this minimal experiment below. My main question is what is the intended way to obtain the log marginal likelihood (log evidence) estimate from a run of Turing's SMC algorithm?. I am using
particles.logE
because the namelogE
suggests that it is the log evidence, but the discrepancy implies that either there is a bug in how logE is computed, or logE is not intended to represent the log evidence (or there is some other issue in how I am using Turing).The code was run with Turing 0.6.11.