|
8 | 8 | #include <mpi.h> |
9 | 9 | #include <nlohmann/json.hpp> |
10 | 10 | #include <boost/math/distributions/normal.hpp> |
| 11 | +#include <boost/math/distributions/empirical_cumulative_distribution_function.hpp> |
11 | 12 |
|
12 | 13 | using namespace chimbuko; |
13 | 14 |
|
@@ -35,7 +36,7 @@ ADOutlier *ADOutlier::set_algorithm(OutlierStatistic stat, const std::string & a |
35 | 36 | return new ADOutlierHBOS(stat, hbos_thres, glob_thres); |
36 | 37 | } |
37 | 38 | else if (algorithm == "copod" || algorithm == "COPOD") { |
38 | | - return new ADOutlierCOPOD(stat, hbos_thres); |
| 39 | + return new ADOutlierCOPOD(stat, hbos_thres); |
39 | 40 | } |
40 | 41 | else { |
41 | 42 | return nullptr; |
@@ -589,11 +590,21 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers, |
589 | 590 | std::vector<double> prob_counts = std::vector<double>(param[func_id].counts().size(), 0.0); |
590 | 591 | double tot_runtimes = std::accumulate(param[func_id].counts().begin(), param[func_id].counts().end(), 0.0); |
591 | 592 |
|
| 593 | + std::vector<double> recon_runtimes = std::vector<double>(tot_runtimes, 0.0); |
| 594 | + int recon_idx = 0; |
| 595 | + for(int i=0; i < param[func_id].counts().size(); i++){ |
| 596 | + int count = param[func_id].counts().at(i); |
| 597 | + for(int j=0; j<count; j++){ |
| 598 | + recon_runtimes.at(recon_idx++) = param[func_id].bin_edges.at(i); |
| 599 | + } |
| 600 | + } |
| 601 | + |
| 602 | + auto func_ecdf = empiricalCDF(recon_runtimes, true); |
| 603 | + |
592 | 604 | for(int i=0; i < param[func_id].counts().size(); i++){ |
593 | 605 | int count = param[func_id].counts().at(i); |
594 | 606 | double p = count / tot_runtimes; |
595 | 607 | prob_counts.at(i) += p; |
596 | | - |
597 | 608 | } |
598 | 609 |
|
599 | 610 | //Create COPOD score vector |
@@ -767,3 +778,9 @@ int ADOutlierCOPOD::np_digitize_get_bin_inds(const double& X, const std::vector< |
767 | 778 |
|
768 | 779 | return ret_val; |
769 | 780 | } |
| 781 | + |
| 782 | +auto ADOutlierCOPOD::empiricalCDF(const std::vector<double>& runtimes, const bool sorted) { |
| 783 | + |
| 784 | + return boost::math::empirical_cumulative_distribution_function(std::move(runtimes), sorted); |
| 785 | + |
| 786 | +} |
0 commit comments