コード例 #1
0
        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");
                }
            }
        }
コード例 #2
0
 public void SealProbabilityMatrix()
 {
     RowsWithDistributions.OptimizeAndSeal();
 }
コード例 #3
0
 internal void FinishDistribution()
 {
     RowsWithDistributions.FinishRow();
 }
コード例 #4
0
 internal void AddTransitionOptimized(int markovChainState, double probability)
 {
     RowsWithDistributions.MergeOrAddColumnValueToCurrentRow(new SparseDoubleMatrix.ColumnValue(StateToColumn(markovChainState), probability));
     Transitions++;
 }
コード例 #5
0
 internal void StartWithNewDistribution()
 {
     RowsWithDistributions.SetRow(RowsWithDistributions.Rows);             //just append one row
     _rowCountOfCurrentState++;
 }
コード例 #6
0
 private void AddTransitionToInitialDistributionUnoptimized(int markovChainState, double probability)
 {
     RowsWithDistributions.AddColumnValueToCurrentRow(new SparseDoubleMatrix.ColumnValue(StateToColumn(markovChainState), probability));
 }