Nonefrequencies xs returns a Map from distinct items in xs' to the number of times they appear.$frequencies $ fromList "bra bra bar"*fromList [(' ',2),('a',3),('b',3),('r',3)]None!"2346 -Uniform distribution over a standard simplex.! StdSimplex k, constructs a standard simplex of dimension k (standard kE-simplex). An element of the simplex represents a vector variable as = (a_0, a_1, ..., a_k). The elements of as are more than or equal to 0 and sum as is always equal to 1." stdSimplex k_ returns a random variable being uniformly distributed over a standard simplex of dimension k.#>An algorithm proposed by Rubinstein & Melamed (1998). See, e.g., S. Onn, I. Weissman. Generating uniform random vectors over a simplex with implications to the volume of a certain polytope and to multivariate extremes.  Ann Oper Res (2011) 189 :331-342. !"$#% !"$# !"$#%None &%More efficient data structure of the & model. The inputs, states, and outputs in &* are represented by their indices. The ', (, and  emissionDist% are represented by matrices. The )@ is a transposed matrix in order to simplify the calculation.*Number of inputs+Number of states,Number of outputs-qPerform one step of the Baum-Welch algorithm and return the updated model and the likelihood of the old model..$Return alphas and scaling variables./%Return betas using scaling variables.0"Return the posterior distribution.1Global error threshold.2 Error matrix q k is required to guarantee that the elements of initial states vector and emission/transition matrix are all larger than zero. k( is assumed to be the number of states. q k$ is given by [ 1 - eps, (1k') eps, ..., (1k') eps ] [ (1#k') eps, 1 - eps, ..., (1Ok') eps ] [ ... ] [ (1k') eps, ..., (1:k') eps, 1 - eps ], where the diagonal elements are 1 - eps and the remains are  (1/k') eps. Here eps" is a small error value (given by 1e-4 ) and  k' = k - 1.&3*+,'()456789-./012:&3*+,'()456789&3*+,'()456789-./012:None ;%More efficient data structure of the ; model. The states and outputs in ;* are represented by their indices. The <, =, and  emissionDist% are represented by matrices. The >@ is a transposed matrix in order to simplify the calculation.?Number of states@Number of outputsAqPerform one step of the Baum-Welch algorithm and return the updated model and the likelihood of the old model.B$Return alphas and scaling variables.C%Return betas using scaling variables.D"Return the posterior distribution.EGlobal error threshold.F Error matrix q k is required to guarantee that the elements of initial states vector and emission/transition matrix are all larger than zero. k( is assumed to be the number of states. q k$ is given by [ 1 - eps, (1k') eps, ..., (1k') eps ] [ (1#k') eps, 1 - eps, ..., (1Ok') eps ] [ ... ] [ (1k') eps, ..., (1:k') eps, 1 - eps ], where the diagonal elements are 1 - eps and the remains are  (1/k') eps. Here eps" is a small error value (given by 1e-4 ) and  k' = k - 1.;G?@<=>HIJKLMABCDEFN;G?@<=>HIJKLM;G?@<=>HIJKLMABCDEFNNone2346O4Probability mass function for discrete distributionsPOQPOPOQNoneVParameter set of the input-output hidden Markov model with discrete emission. This e assumes that the inputs affect only the transition probabilities. The model schema is as follows.  x_0 x_1 x_n | | v v z_0 -> z_1 -> ... -> z_n | | | v v v y_0 y_1 y_n Here, [x_0, x_1, ..., x_n] are given inputs, [z_0, z_1, ..., z_n] are hidden states, and [y_0, y_1, ..., y_n] are observed outputs. z_0 is determined by the  . For  i = 1, ..., n, z_i is determined by the  conditioned by x_i and z_{i-1} . For  i = 0, ..., n, y_i is determined by the   conditioned by z_i.)Categorical distribution of initial stateUCategorical distribution of next state conditioned by the input and previous state ECategorical distribution of output conditioned by the hidden state init inputs states outputs1 returns a random variable of models with the inputs, states, and outputs?, wherein parameters are sampled from uniform distributions. withEmission model xs ys! returns a model in which the  / is updated by re-estimations using the inputs xs and outputs ys. The  Z is set to be normalized histograms each of which is calculated from segumentations of ys: based on the Viterbi state path. If the lengths of xs and ysJ are different, the longer one is cut by the length of the shorter one. cReturn the Euclidean distance between two models that have the same inputs, states, and outputs. viterbi model xs ys4 performs the Viterbi algorithm using the inputs xs and outputs ysY, and returns the most likely state path and its log likelihood. If the lengths of xs and ysJ are different, the longer one is cut by the length of the shorter one.baumWelch model xs ysC iteratively performs the Baum-Welch algorithm using the inputs xs and outputs ysh, and returns a list of updated models and their corresponding log likelihoods. If the lengths of xs and ysJ are different, the longer one is cut by the length of the shorter one.baumWelch' model xs7 performs the Baum-Welch algorithm using the inputs xs and outputs ys?, and returns a model locally maximizing its log likelihood.simulate model xs: generates a Markov process coinciding with the inputs xs using the model5, and returns its state path and observed outputs.R8Check if the model is valid in the sense of whether the  and  are not empty.SBCheck if the two models have the same inputs, states, and outputs.TPCheck if all the elements of the given inputs (outputs) are contained in the  () of the model.UConvert internal  to .VConvert  to internal . The initialStateDist', transitionDist', and emissionDistT' are normalized. RSTUVWX   RSTUVWXNonecParameter set of the hidden Markov model with discrete emission. The model schema is as follows. | z_0 -> z_1 -> ... -> z_n | | | v v v x_0 x_1 x_n Here, [z_0, z_1, ..., z_n] are hidden states and [x_0, x_1, ..., x_n] are observed outputs. z_0 is determined by the  . For  i = 1, ..., n, z_i is determined by the  conditioned by z_{i-1} . For  i = 0, ..., n, x_i is determined by the  conditioned by z_i.)Categorical distribution of initial stateKCategorical distribution of next state conditioned by the previous stateECategorical distribution of output conditioned by the hidden stateinit states outputs1 returns a random variable of models with the states and outputs?, wherein parameters are sampled from uniform distributions.model `withEmission` xs! returns a model in which the < is updated by re-estimations using the observed outputs xs. The Z is set to be normalized histograms each of which is calculated from segumentations of xs$ based on the Viterbi state path.ZReturn the Euclidean distance between two models that have the same states and outputs.viterbi model xs> performs the Viterbi algorithm using the observed outputs xsC, and returns the most likely state path and its log likelihood.baumWelch model xsM iteratively performs the Baum-Welch algorithm using the observed outputs xsR, and returns a list of updated models and their corresponding log likelihoods.baumWelch' model xsA performs the Baum-Welch algorithm using the observed outputs xs?, and returns a model locally maximizing its log likelihood.simulate model t& generates a Markov process of length t using the model), and returns its state path and outputs.Y8Check if the model is valid in the sense of whether the  and  are not empty.Z9Check if the two models have the same states and outputs.[JCheck if all the elements of the observed outputs are contained in the  of the model.\Convert internal  to .]Convert  to internal . The initialStateDist', transitionDist', and emissionDistT' are normalized.YZ[\]^_YZ[\]^_`            !"#$%&' (  !"#$%&')*+,-./0123-./01245learning-hmm-0.3.2.2Learning.IOHMM Learning.HMMData.Vector.Generic.Extra Data.Random.Distribution.SimplexLearning.IOHMM.InternalLearning.HMM.InternalData.Random.Distribution.Extra LogLikelihoodIOHMMinputsstatesoutputsinitialStateDisttransitionDist emissionDistinit withEmissioneuclideanDistanceviterbi baumWelch baumWelch'simulateHMM frequencies StdSimplex stdSimplexfractionalStdSimplex stdSimplexT$fDistributionStdSimplex[] emissionDistTnInputsnStatesnOutputs baumWelch1forwardbackward posteriorepsq $fNFDataIOHMM $fNFDataHMMpmfPMF$fPMFCategoricala checkModelIncheckTwoModelsIn checkDataIn fromInternal toInternalerrorIn $fShowIOHMM $fShowHMM