MeanEstimate.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _MeanEstimate_h_
  2. #define _MeanEstimate_h_
  3. #include "../Pattern/Singleton.h"
  4. #include <cstdio>
  5. #include <map>
  6. #include <vector>
  7. #include <functional>
  8. #define VARIATION_COEF 0.02
  9. class CDebugOutput : public Singleton< CDebugOutput >
  10. {
  11. public:
  12. void Init();
  13. void OpenFile();
  14. void WriteToFile();
  15. std::map< int, double > m_diameter;
  16. std::map< int, double > m_estimate2;
  17. std::map< int, double > m_distensibility;
  18. std::map< int, double > m_distensibility20;
  19. FILE* m_file;
  20. int currentIndex;
  21. int m_minIndex;
  22. int m_maxIndex;
  23. protected:
  24. friend class Singleton< CDebugOutput >;
  25. CDebugOutput();
  26. };
  27. class CMeanEstimate
  28. {
  29. public:
  30. static bool IsANumber(double x);
  31. static void RemoveNanValues(std::vector<double> *A);
  32. static void RemoveValues(std::vector<double> *A, double value);
  33. static void RemoveOutOfBoundsValues(std::vector<double> *A, double percent);//precent : Bounds are the means +/- percent of the mean
  34. static void FindMinMax(std::vector<double> *A, double &min, double &max);
  35. static void FindMinMaxWithinBoundsValues(std::vector<double> *A, double percent, double &min, double &max);
  36. static double GetVariance(std::vector<double> *A);
  37. static double GetStandardDeviation(std::vector<double> *A);
  38. static double GetMean(std::vector<double> *A);
  39. static double GetMeanEstimate(std::vector<double> *A, double similarityCoef);
  40. static double GetMeanEstimate(std::vector<double> *A);
  41. static double GetMeanEstimateFileOutput(std::vector<double> *A, double similarityCoef=VARIATION_COEF);
  42. static void writeFileOutput(char* text);
  43. static void endFileOutput();
  44. static void PrintMeanEstimate(std::vector<double> *A, std::vector<double> *B);
  45. static void PrintMeanEstimate(std::vector<double> *A, std::vector<double> *B, double similarityCoef);
  46. static void startFileOutput(char *filename);
  47. static void titleFileOutput(char *title, std::vector<double> *A, std::vector<double> *B);
  48. static void titleFileOutput(std::vector<double> *A);
  49. //static void OutputToFile(char* filename, std::vector<double> *A, std::vector<double *B);
  50. protected:
  51. CMeanEstimate();
  52. virtual ~CMeanEstimate();
  53. };
  54. #endif