title: Understanding Viterbi Algorithm
body: <p>I'm trying to implement some code from <a href="http://code.soundsoftware.ac.uk/projects/qm-dsp/repository/entry/dsp/segmentation/cluster_segmenter.c" rel="nofollow">here</a></p>
  
  <p>And I have trained the HMM with my coefficients but do not understand how the Viterbi Decoder algorithm works, for example: </p>
  
  <pre><code> viterbi_decode(MFCC, M, model, q);
   where MFCC = coefficents 
   M = size of MFCC
   model = Model of HMM training using the MFCC coefficients 
   q = unknown (believed to be the outputted path).
  </code></pre>
  
  <p>But here is what I do not understand: I am attempting to compare two speech signals (training, sample) to find out the closest possible match. With the DTW algorithm for example, a single integer is returned where I can then find the closest, however, with this algorithm it returns a <code>int* array</code> and therefore differentiating is difficult. </p>
  
  <p>Here is how the current program works:</p>
  
  <pre><code>vector&lt;DIMENSIONS_2&gt; MFCC = mfcc.transform(rawData, sample_rate);
  
  int N = MFCC.size();
  int M = 13;
  
  double** mfcc_setup = setupHMM(MFCC, N, M);
  
  model_t* model = hmm_init(mfcc_setup, N, M, 10);
  
  hmm_train(mfcc_setup, N, model);
  
  int* q = new int[N];
  
  viterbi_decode(mfcc_setup, M, model, q); 
  </code></pre>
  
  <p>Could anyone please tell me how the Viterbi Decoder works for the problem of identifying which is the best path to take from the training, to the input? I've tried both the Euclidean distance as well as the Hamming Distance on the decode path <code>(q)</code> but had no such luck.</p>
  
  <p>Any help would be greatly appreciated  </p>