diff --git a/mlpp/gauss_markov_checker/gauss_markov_checker.cpp b/mlpp/gauss_markov_checker/gauss_markov_checker.cpp index 3efef30..8cea1ec 100644 --- a/mlpp/gauss_markov_checker/gauss_markov_checker.cpp +++ b/mlpp/gauss_markov_checker/gauss_markov_checker.cpp @@ -8,7 +8,6 @@ #include "../stat/stat.h" #include - void MLPPGaussMarkovChecker::checkGMConditions(std::vector eps) { bool condition1 = arithmeticMean(eps); bool condition2 = homoscedasticity(eps); @@ -22,36 +21,40 @@ void MLPPGaussMarkovChecker::checkGMConditions(std::vector eps) { } bool MLPPGaussMarkovChecker::arithmeticMean(std::vector eps) { - MLPPStat stat; + MLPPStat stat; if (stat.mean(eps) == 0) { - return 1; + return true; } else { - return 0; + return false; } } bool MLPPGaussMarkovChecker::homoscedasticity(std::vector eps) { - MLPPStat stat; + MLPPStat stat; real_t currentVar = (eps[0] - stat.mean(eps)) * (eps[0] - stat.mean(eps)) / eps.size(); - for (int i = 0; i < eps.size(); i++) { + for (uint32_t i = 0; i < eps.size(); i++) { if (currentVar != (eps[i] - stat.mean(eps)) * (eps[i] - stat.mean(eps)) / eps.size()) { - return 0; + return false; } } - return 1; + + return true; } bool MLPPGaussMarkovChecker::exogeneity(std::vector eps) { - MLPPStat stat; - for (int i = 0; i < eps.size(); i++) { - for (int j = 0; j < eps.size(); j++) { + MLPPStat stat; + for (uint32_t i = 0; i < eps.size(); i++) { + for (uint32_t j = 0; j < eps.size(); j++) { if (i != j) { if ((eps[i] - stat.mean(eps)) * (eps[j] - stat.mean(eps)) / eps.size() != 0) { - return 0; + return false; } } } } - return 1; + + return true; } +void MLPPGaussMarkovChecker::_bind_methods() { +} diff --git a/mlpp/gauss_markov_checker/gauss_markov_checker.h b/mlpp/gauss_markov_checker/gauss_markov_checker.h index 34f14dc..7afc42b 100644 --- a/mlpp/gauss_markov_checker/gauss_markov_checker.h +++ b/mlpp/gauss_markov_checker/gauss_markov_checker.h @@ -10,11 +10,14 @@ #include "core/math/math_defs.h" +#include "core/object/reference.h" + #include #include +class MLPPGaussMarkovChecker : public Reference { + GDCLASS(MLPPGaussMarkovChecker, Reference); -class MLPPGaussMarkovChecker { public: void checkGMConditions(std::vector eps); @@ -22,8 +25,9 @@ public: bool arithmeticMean(std::vector eps); // 1) Arithmetic Mean of 0. bool homoscedasticity(std::vector eps); // 2) Homoscedasticity bool exogeneity(std::vector eps); // 3) Cov of any 2 non-equal eps values = 0. -private: + +protected: + static void _bind_methods(); }; - #endif /* GaussMarkovChecker_hpp */ diff --git a/register_types.cpp b/register_types.cpp index 2720b8a..cbaacc0 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -35,6 +35,7 @@ SOFTWARE. #include "mlpp/stat/stat.h" #include "mlpp/numerical_analysis/numerical_analysis.h" #include "mlpp/hypothesis_testing/hypothesis_testing.h" +#include "mlpp/gauss_markov_checker/gauss_markov_checker.h" #include "mlpp/hidden_layer/hidden_layer.h" #include "mlpp/multi_output_layer/multi_output_layer.h" @@ -74,6 +75,7 @@ void register_pmlpp_types(ModuleRegistrationLevel p_level) { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();