title: how to calculate roc curves?
body: <p>I write a classifier (Gaussian Mixture Model) to classify five human actions. For every observation the classifier compute the posterior probability to belong to a cluster.</p>
  
  <p>I want to valutate the performance of my system parameterized with a threshold, with values from 0 to 100. For every threshold values, for every observation, if the probability of belonging to one of cluster is greater than threshold I accept the result of the classifier otherwise I discard it.</p>
  
  <p>For every threshold values I compute the number of true-positive, true-negative, false-positive, false-negative.</p>
  
  <p>Than I compute the two function: sensitivity and specificity as</p>
  
  <pre><code>sensitivity = TP/(TP+FN);
  
  specificity=TN/(TN+FP);
  </code></pre>
  
  <p>In matlab:</p>
  
  <pre><code>plot(1-specificity,sensitivity);
  </code></pre>
  
  <p>to have the ROC curve. But the result isn't what I expect.</p>
  
  <p>This is the plot of the functions of discards, errors, corrects, sensitivity and specificity varying the threshold of one action.</p>
  
  <p><img src="https://i.stack.imgur.com/0JVNU.png" alt="This is the plot of the functions of discards, errors, corrects, sensitivity and specificity varying the threshold"></p>
  
  <p>This is the plot of ROC curve of one action
  <img src="https://i.stack.imgur.com/X2MXD.png" alt="This is the plot of ROC curve"></p>
  
  <p>This is the stem of ROC curve for the same action
  <img src="https://i.stack.imgur.com/DpaO2.png" alt="enter image description here"></p>
  
  <p>I am wrong, but i don't know where. Perhaps I do wrong the calculating of FP, FN, TP, TN especially when the result of the classifier is minor of the threshold, so I have a discard. What I have to incremente when there is a discard?</p>