#include #include #include #include #include namespace distribution { double inner_transform_warpper( double input, double coeff, std::function transform_func) { bool is_neg = false; if (input < 0) { is_neg = true; input = -input; } double ret = transform_func(input, coeff); if (is_neg == true) { ret = -ret; } return ret; } dlib::running_stats DataMapping::get_running_stats() { return this->rs_; } double DataMapping::reverse_transform(double input) { return box_cox_reverse(input, c_, lambda_); } int DataMapping::set_running_stats(dlib::running_stats prev_rs) { this->rs_ = prev_rs; if (rs_.skewness() > 0) { is_positive_skewed_ = true; } if (rs_.skewness() < 0) { is_positive_skewed_ = false; } return 0; } std::vector DataMapping::transform( const std::vector& input) { if (rs_.min() < 0) { c_ = (rs_.min()) * (-2); } else { c_ = 0; } std::vector input_cp; size_t loop_count = 0; while (loop_count < 1000 && abs(rs_.skewness()) > 0) { input_cp = input; rs_.clear(); lambda_ += delta_; for (auto& x : input_cp) { x = box_cox(x, c_, lambda_); rs_.add(x); } } return input_cp; } double DataMapping::get_lambda() { return this->lambda_; } } // namespace distribution