Commit 94aa5080 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Try making RHEL6 happy.

parent 3a007ca2
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <functional> #include <functional>
#include <boost/accumulators/accumulators.hpp> #include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/min.hpp> #include <boost/accumulators/statistics/min.hpp>
#include <boost/accumulators/statistics/max.hpp> #include <boost/accumulators/statistics/max.hpp>
#include <boost/accumulators/statistics/variance.hpp> #include <boost/accumulators/statistics/variance.hpp>
...@@ -151,46 +152,46 @@ std::vector<double> getModifiedZscore(const vector<TYPE> &data, ...@@ -151,46 +152,46 @@ std::vector<double> getModifiedZscore(const vector<TYPE> &data,
*/ */
template <typename TYPE> template <typename TYPE>
Statistics getStatistics(const vector<TYPE> &data, const unsigned int flags) { Statistics getStatistics(const vector<TYPE> &data, const unsigned int flags) {
Statistics stats = getNanStatistics(); Statistics statistics = getNanStatistics();
size_t num_data = data.size(); // cache since it is frequently used size_t num_data = data.size(); // cache since it is frequently used
if (num_data == 0) { // don't do anything if (num_data == 0) { // don't do anything
return stats; return statistics;
} }
// calculate the mean if this or the stddev is requested // calculate the mean if this or the stddev is requested
const bool stddev = ((flags & StatOptions::UncorrectedStdDev) || const bool stddev = ((flags & StatOptions::UncorrectedStdDev) ||
(flags & StatOptions::CorrectedStdDev)); (flags & StatOptions::CorrectedStdDev));
if (stddev) { if (stddev) {
using namespace boost::accumulators; using namespace boost::accumulators;
accumulator_set<TYPE, features<tag::min, tag::max, tag::variance>> acc; accumulator_set<double, stats<tag::min, tag::max, tag::variance>> acc;
for (auto &value : data) { for (auto &value : data) {
acc(value); acc(static_cast<double>(value));
} }
stats.minimum = min(acc); statistics.minimum = min(acc);
stats.maximum = max(acc); statistics.maximum = max(acc);
stats.mean = mean(acc); statistics.mean = mean(acc);
double var = variance(acc); double var = variance(acc);
if (flags & StatOptions::CorrectedStdDev) { if (flags & StatOptions::CorrectedStdDev) {
double ndofs = static_cast<double>(data.size()); double ndofs = static_cast<double>(data.size());
var *= ndofs / (ndofs - 1.0); var *= ndofs / (ndofs - 1.0);
} }
stats.standard_deviation = std::sqrt(var); statistics.standard_deviation = std::sqrt(var);
} else if (flags & StatOptions::Mean) { } else if (flags & StatOptions::Mean) {
using namespace boost::accumulators; using namespace boost::accumulators;
accumulator_set<TYPE, features<tag::mean>> acc; accumulator_set<double, stats<tag::mean>> acc;
for (auto &value : data) { for (auto &value : data) {
acc(value); acc(static_cast<double>(value));
} }
stats.mean = mean(acc); statistics.mean = mean(acc);
} }
// calculate the median if requested // calculate the median if requested
if (flags & StatOptions::Median) { if (flags & StatOptions::Median) {
stats.median = getMedian(data, num_data, flags & StatOptions::SortedData); statistics.median = getMedian(data, num_data, flags & StatOptions::SortedData);
} }
return stats; return statistics;
} }
/// Getting statistics of a string array should just give a bunch of NaNs /// Getting statistics of a string array should just give a bunch of NaNs
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment