public void ValidateStates() { var enumerator = RowsWithDistributions.GetEnumerator(); //every row contains one probability distribution (also the initial distribution) while (enumerator.MoveNextRow()) { // for each state there is a row. The sum of all columns in a row should be 1.0 var probability = 0.0; while (enumerator.MoveNextColumn()) { if (enumerator.CurrentColumnValue != null) { probability += enumerator.CurrentColumnValue.Value.Value; } else { throw new Exception("Entry must not be null"); } } if (!Probability.IsOne(probability, 0.000000001)) { throw new Exception("Probabilities should sum up to 1"); } } }
public void SealProbabilityMatrix() { RowsWithDistributions.OptimizeAndSeal(); }
internal void FinishDistribution() { RowsWithDistributions.FinishRow(); }
internal void AddTransitionOptimized(int markovChainState, double probability) { RowsWithDistributions.MergeOrAddColumnValueToCurrentRow(new SparseDoubleMatrix.ColumnValue(StateToColumn(markovChainState), probability)); Transitions++; }
internal void StartWithNewDistribution() { RowsWithDistributions.SetRow(RowsWithDistributions.Rows); //just append one row _rowCountOfCurrentState++; }
private void AddTransitionToInitialDistributionUnoptimized(int markovChainState, double probability) { RowsWithDistributions.AddColumnValueToCurrentRow(new SparseDoubleMatrix.ColumnValue(StateToColumn(markovChainState), probability)); }