ZScore.cpp 720 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "ZScore.h"
  2. #include "MathUtil.h"
  3. ZScore::ZScore(const QVector<ZScore::EvaluateIndex> &rMat) : originMat(rMat)
  4. {
  5. calcZScoreMat();
  6. }
  7. const QVector<ZScore::EvaluateIndex> &ZScore::zScoreResult()
  8. {
  9. return zScoreMat;
  10. }
  11. ZScore::Relations ZScore::getRelations() const
  12. {
  13. //没计算
  14. return Relations();
  15. }
  16. void ZScore::calcZScoreMat()
  17. {
  18. if (originMat.count() == 0 || originMat[0].count() == 0) {
  19. return;
  20. }
  21. for (auto index : originMat) {
  22. std::pair<double, double> rst = Helper::meanAndStandardDeviation(index);
  23. ZScore::EvaluateIndex zs;
  24. for (auto v : index) {
  25. zs << (v - rst.first) / rst.second;
  26. }
  27. zScoreMat << zs;
  28. }
  29. }