title: How to calculate the probability with a Gaussian Mixture Model in Matlab
body: <p>This problem is solved. Thank you @dpwe<br>
  I first make the GMM by gmdistribution. Then I want to have a function that can return the probability of my Observation. That is:<br></p>
  
  <pre><code>GMMObject = gmdistribution(Vec_Mean, Matrix_Covariance, Vec_Weight);
  Probability = posterior(GMMObject, Vec_Observation) * Vec_Weight;
  </code></pre>
  
  <p>The value of <code>Probability</code> should equal to p(x) <br>
  <img src="https://latex.codecogs.com/gif.latex?p%28x%29%20%3D%20%5Csum_%7Bk%3D1%7D%5E%7BK%7Dw_%7Bk%7D%5Cmathit%7BN%7D%28x%7Cu_%7Bk%7D%2C%5CSigma%20_%7Bk%7D%29" alt=""><br>
  But I find that <code>log(Probability)</code> is not equal to <code>nlogl</code> where:<br></p>
  
  <pre><code>[Dummy, nlogl] = posterior(GMMObject, Vec_Observation)
  </code></pre>
  
  <p><br>
  So I am wondering where is my mistake.</p>