eis/eqpalg/feature_extraction/distribution.h

132 lines
3.1 KiB
C
Raw Normal View History

#pragma once
/**
* @file dist.h
* @brief
*
*
* @author your name (you@domain.com)
* @version 0.1
* @date 2024-02-21
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include <dlib/statistics.h>
#include <log4cplus/LOG.h>
#include <algorithm>
#include <boost/math/distributions/chi_squared.hpp>
#include <boost/math/distributions/normal.hpp>
#include <boost/math/distributions/skew_normal.hpp>
#include <boost/math/distributions/students_t.hpp>
#include <memory>
#include <tuple>
#include <vector>
#include "mix_cc/type/range.h"
namespace DAA {
using boost::math::quantile;
/**
* @brief
* Prob确定出错的最大可能性
*
*
*
*/
class Dist {
public:
enum class DistTypes {
unknown,
student_t,
normal,
skew_normal
};
constexpr static double test_prec = 0.01;
protected:
DistTypes dist_type_;
bool valid_;
dlib::running_stats<double> rs_;
mix_cc::float_range_t legal_range_;
std::string rule_id_;
std::shared_ptr<boost::math::normal> normal_;
std::shared_ptr<boost::math::students_t> students_t_;
std::shared_ptr<boost::math::skew_normal> skew_normal_;
std::unique_ptr<LOG> logger_;
double predefied_prob_ = 0.975;
double prob_ = 0.5;
public:
/**
* @brief
*/
Dist(/* args */);
/**
* @brief Destroy the Dist object
*/
~Dist();
/**
* @brief
* @return DistTypes
*/
DistTypes get_distribution_type() const;
/**
* @brief
* @param prob
* @return int
*/
int set_predefined_prob(double prob);
/**
* @brief Get the shifted prob object
* @return double
*/
double get_shifted_prob() const;
/**
* @brief
* ,
* @param rs dlib::running_stats
* @param tmp_data My Param doc
* @return int
*/
int auto_test(dlib::running_stats<double> rs,
const std::vector<double>& tmp_data);
/**
* @brief
* @return true
* @return false
*/
bool valid() const;
/**
* @brief
* @return mix_cc::float_range_t
*/
mix_cc::float_range_t get_range() const;
protected:
/**
* @brief
* @param prob
* @param tmp_data
* @return double
*/
double get_error_rate_type_1(const double& prob,
const std::vector<double>& tmp_data);
/**
* @brief
* @param prob
* @return mix_cc::float_range_t
*/
mix_cc::float_range_t get_range(double prob);
};
}