Closed GuilhermePFM closed 4 years ago
I think it just needs to change this function:
function rand(rng::AbstractRNG, hmm::AbstractHMM{Multivariate}, z::AbstractVector{<:Integer})
y = Matrix{Float64}(undef, length(z), size(hmm, 1))
for t in eachindex(
y[t,:] = rand(rng, hmm.B[z[t]])
end
y
end
to y = Matrix{Float64}(undef, length(z), size(hmm, 2))
I tested here and it seems to be working. If that is ok with you I can open a PR with the fix and also add a new test for that.
Hi Guilherme,
You're right, thanks for reporting this bug! Feel free to make a PR if you have the time :)
You can add a test in unit.jl
: https://github.com/maxmouchet/HMMBase.jl/blob/master/test/unit.jl#L48-L76
Maybe you can add a third hmm (hmm3
) which has a different number of states and observations, with a comment that links to this issue.
Ok! Will do this right now, thank you
Hello,
Thank you for this very nice package. I am just learning HMM and I would like to know if is it possible to estimate a HMM with 2 hidden states for 3 observations like this:
I tried it but it gives an error of dimension mismatch:
ERROR: DimensionMismatch("tried to assign 3-element array to 1×2 destination")
Am I doing something wrong here?