-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
70 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
PermutedHMM{H<:AbstractHMM} | ||
Wrapper around an `AbstractHMM` that permutes its states. | ||
This is computationally inefficient and mostly useful for evaluation. | ||
# Fields | ||
- `hmm:H`: the old HMM | ||
- `perm::Vector{Int}`: a permutation such that state `i` in the new HMM corresponds to state `perm[i]` in the old. | ||
""" | ||
struct PermutedHMM{H<:AbstractHMM} <: AbstractHMM | ||
hmm::H | ||
perm::Vector{Int} | ||
end | ||
|
||
Base.length(p::PermutedHMM) = length(p.hmm) | ||
|
||
HMMs.initial_distribution(p::PermutedHMM) = initial_distribution(p.hmm)[p.perm] | ||
|
||
function HMMs.transition_matrix(p::PermutedHMM) | ||
return transition_matrix(p.hmm)[p.perm, :][:, p.perm] | ||
end | ||
|
||
function HMMs.obs_distribution(p::PermutedHMM, i::Integer) | ||
return obs_distribution(p.hmm, p.perm[i]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters