/// <summary> /// Returns the next state of the model based on the current state. /// </summary> /// <param name="currentState">current state index. If set to null then next state is calculated /// based on the initial state distribution Pi</param> /// <returns>next state of the model</returns> private int GetNextState(int?currentState) { if (currentState == null) { return(ProbabilityHandler.RealizeProbability(Model.Pi)); } else { double[] stateDistribution = MatrixUtils.GetRow(Model.A, (int)currentState); return(ProbabilityHandler.RealizeProbability(stateDistribution)); } }
protected override List <int> GenerateWord(int currentState, int currentPeriod, int symbolNumber) { List <int> result = new List <int>(); double[] errorDistribution = GenerateErrorDistribution(currentState, currentPeriod); double[] symbolDistribution = MatrixUtils.GetRow(Model.B, currentState); for (int i = 0; i < symbolNumber; i++) { bool hasError = ProbabilityHandler.RealizeBinaryProbability(errorDistribution[i]) == 1; int symbol; if (hasError) { symbol = ProbabilityHandler.RealizeProbability(symbolDistribution) + 1; } else { symbol = 0; } result.Add(symbol); } return(result); }
protected override List <int> GenerateWord(int currentState, int currentPeriod, int symbolNumber) { List <int> result = new List <int>(); double[] symbolDistribution = MatrixUtils.GetRow(Model.B, currentState); for (int i = 0; i < symbolNumber; i++) { result.Add(ProbabilityHandler.RealizeProbability(symbolDistribution)); } return(result); }