test_Discriminant.praat 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # test_Discriminant.praat
  2. # djmw 20110518, 20141030, 20150128
  3. appendInfoLine: "test_Discriminant"
  4. # old format
  5. appendInfoLine: tab$ + "Read Discriminant format 0 from disk"
  6. discriminant[1] = Read from file: "pols_50males_format0.Discriminant"
  7. tableOfReal = Create TableOfReal (Pols 1973): "no"
  8. Formula: "log10(self)"
  9. discriminant[2] = To Discriminant
  10. appendInfoLine: tab$ + "Query old and new Discriminant"
  11. @query: discriminant[1]
  12. @query: discriminant[2]
  13. appendInfoLine: tab$ + "Assert old and new Discriminant classify the same"
  14. @classify: discriminant[1], tableOfReal, 1
  15. @classify: discriminant[2], tableOfReal, 2
  16. assert classify.fc[1] = classify.fc[2]
  17. procedure classify: .discriminant, .tableOfReal, .index
  18. selectObject: .discriminant, .tableOfReal
  19. .classificationTable = To ClassificationTable: "yes", "yes"
  20. .confusion = To Confusion: "no"
  21. .fc[.index] = Get fraction correct
  22. assert .fc[.index] -0.74 < 0.00001
  23. removeObject: .classificationTable, .confusion
  24. endproc
  25. procedure query: .discriminant
  26. for .ieigen to 3
  27. .eigenvalue[.ieigen] = Get eigenvalue: .ieigen
  28. endfor
  29. .numberOfEigenvectors = Get number of eigenvectors
  30. .dimension = Get eigenvector dimension
  31. assert (.eigenvalue[1] - 21.139) < 0.00001
  32. assert (.eigenvalue[2] - 4.35530) < 0.00001
  33. assert (.eigenvalue[3] - 0.68289) < 0.00001
  34. assert .numberOfEigenvectors = 3
  35. assert .dimension = 3
  36. endproc
  37. removeObject: discriminant[2], tableOfReal, discriminant[1]
  38. appendInfoLine: "test_Discriminant OK"