Utilities
HMMBase.gettransmat
— Functiongettransmat(seq; relabel = false) -> (Dict, Matrix)
Return the transition matrix associated to the label sequence seq
. The labels must be positive integer.
Arguments
seq::Vector{<:Integer}
: positive label sequence.
Keyword Arguments
relabel::Bool = false
: if set to true the sequence will be made contiguous. E.g.[7,7,9,9,1,1]
will become[2,2,3,3,1,1]
.
Output
Dict{Integer,Integer}
: the mapping between the original and the new labels.Matrix{Float64}
: the transition matrix.
HMMBase.randtransmat
— Functionrandtransmat([rng,] prior) -> Matrix{Float64}
Generate a transition matrix where each row is sampled from prior
. The prior must be a multivariate probability distribution, such as a Dirichlet distribution.
Arguments
prior::MultivariateDistribution
: distribution over the transition matrix rows.
Example
A = randtransmat(Dirichlet([0.1, 0.1, 0.1]))
randtransmat([rng, ]K, α = 1.0) -> Matrix{Float64}
Generate a transition matrix where each row is sampled from a Dirichlet distribution of dimension K
and concentration parameter α
.
Arguments
K::Integer
: number of states.α::Float64 = 1.0
: concentration parameter of the Dirichlet distribution.
Example
A = randtransmat(4)
HMMBase.remapseq
— Functionremapseq(seq, ref) -> Vector{Integer}
Find the permutations of seq
indices that maximize the overlap with ref
.
Arguments
seq::Vector{Integer}
: sequence to be remapped.ref::Vector{Integer}
: reference sequence.
Example
ref = [1,1,2,2,3,3]
seq = [2,2,3,3,1,1]
remapseq(seq, ref)
# [1,1,2,2,3,3]