Skip to content

Instantly share code, notes, and snippets.

@DimChtz
Last active November 8, 2017 10:59
Show Gist options
  • Select an option

  • Save DimChtz/9a95fe2a89370f9667089d8b1aa16028 to your computer and use it in GitHub Desktop.

Select an option

Save DimChtz/9a95fe2a89370f9667089d8b1aa16028 to your computer and use it in GitHub Desktop.
A function that calculates AUC using sensitivity and specificity in Matlab.
function[auc] = calcAUC(sens, spec)
tpr = sens;
fpr = 1 - spec;
[~, indices] = sort(sqrt(fpr.^2 + tpr.^2));
tpr = tpr(indices);
fpr = fpr(indices);
auc = trapz([0.0 fpr 1.0], [0.0 tpr 1.0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment