public void BuildMatrix(string matrix)
        {
            matrix = matrix.Replace(" ", "");
            matrix = matrix.Replace("[", "");
            matrix = matrix.Replace("]", "");

            string[] separator  = { Environment.NewLine };
            string[] matrixRows = matrix.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            List <double> valeurs = new List <double>();

            foreach (string row in matrixRows)
            {
                string[] result = row.Split(';');
                foreach (string e in result)
                {
                    valeurs.Add(Double.Parse(e));
                }
            }

            _row    = (uint)matrixRows.Length;
            _col    = (uint)(valeurs.Count / matrixRows.Length);
            _matrix = new double[_row, _col];

            for (int i = 0; i < _row; i++)
            {
                for (int j = 0; j < _col; j++)
                {
                    _matrix[i, j] = valeurs[i * valeurs.Count / matrixRows.Length + j];
                }
            }

            _rowStates = MarkovMatrix.EmptyStates(_row);
            _colStates = MarkovMatrix.EmptyStates(_col);
        }
Exemple #2
0
 public MarkovChain(uint size, MarkovMatrix matrix, MarkovMatrix startProb)
 {
     _size            = size;
     TransitionMatrix = matrix;
     StartProb        = startProb;
     InitStartState();
 }
 /// <summary>
 /// Initialise une nouvelle instance de la classe MarkovChain
 /// </summary>
 /// <param name="size">taille de la matrice de transition</param>
 public MarkovChain(uint size) :
     this(
         size,
         new MarkovMatrix("transition matrix", size, size),
         new MarkovMatrix("start matrix", 1, size, MarkovMatrix.EquiprobableMatrix(1, size))
         )
 {
 }
 /// <summary>
 /// Initialise une nouvelle instance de la classe MarkovChain
 /// </summary>
 /// <param name="size">taille de la matrice de transition</param>
 /// <param name="matrix">matrice de transition</param>
 public MarkovChain(uint size, MarkovMatrix matrix) :
     this(
         size,
         matrix,
         new MarkovMatrix("start matrix", 1, size, MarkovMatrix.EquiprobableMatrix(1, size))
         )
 {
 }
Exemple #5
0
 public MarkovChain(MarkovChain markovChain)
 {
     if (markovChain == null)
     {
         throw new ArgumentNullException();
     }
     _size            = (uint)markovChain.Size;
     TransitionMatrix = markovChain.TransitionMatrix;
     StartProb        = markovChain.StartProb;
     StartState       = markovChain.StartState;
     CurrentState     = markovChain.CurrentState;
 }
Exemple #6
0
 public MarkovMatrix(MarkovMatrix matrix)
 {
     if (matrix == null)
     {
         throw new ArgumentNullException();
     }
     _row      = matrix.Row;
     _col      = matrix.Col;
     Matrix    = matrix.Matrix;
     RowStates = matrix.RowStates;
     ColStates = matrix.ColStates;
 }
Exemple #7
0
 public MarkovChain(uint size, MarkovMatrix matrix) :
     this(size, matrix, new MarkovMatrix(1, size))
 {
 }
Exemple #8
0
 public HiddenMarkovModel(uint size, MarkovMatrix matrix, List <MarkovMatrix> emissionMatrix) :
     base(size, matrix)
 {
     EmissionMatrix = emissionMatrix;
 }