/// <summary> /// /// </summary> /// <param name="A">Transition matrix</param> /// <param name="B">Emision matrix</param> /// <returns></returns> public static HiddenMarkovModel FromMatrices(double[,] A, double[,] B, double[] pi, bool isLog = false) { HiddenMarkovModel model = new HiddenMarkovModel(A.GetLength(0), B.GetLength(1)); if (!isLog) { model.logTransition = MathE.elnify(A); model.logEmission = MathE.elnify(B); model.logPi = MathE.elnify(pi); } else { model.logTransition = A; model.logEmission = B; model.logPi = pi; } return(model); }
public void UniformRandomPriors() { logPi = MathE.elnify(NormalMass(logPi.Length)); for (int i = 0; i < logTransition.GetLength(0); i++) { double[] trans = MathE.elnify(NormalMass(states)); for (int j = 0; j < logTransition.GetLength(0); j++) { logTransition[i, j] = trans[j]; } } for (int i = 0; i < logEmission.GetLength(0); i++) { double[] ems = MathE.elnify(NormalMass(observationSymbols)); for (int j = 0; j < logEmission.GetLength(1); j++) { logEmission[i, j] = ems[j]; } } }