mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-12-22 15:06:47 +01:00
Removed new things from MLPPStatOld.
This commit is contained in:
parent
a30a92171d
commit
aab33650b7
@ -22,13 +22,6 @@ real_t MLPPStatOld::b1Estimation(const std::vector<real_t> &x, const std::vector
|
||||
return covariance(x, y) / variance(x);
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::b0_estimation(const Ref<MLPPVector> &x, const Ref<MLPPVector> &y) {
|
||||
return meanv(y) - b1_estimation(x, y) * meanv(x);
|
||||
}
|
||||
real_t MLPPStatOld::b1_estimation(const Ref<MLPPVector> &x, const Ref<MLPPVector> &y) {
|
||||
return covariancev(x, y) / variancev(x);
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::mean(const std::vector<real_t> &x) {
|
||||
real_t sum = 0;
|
||||
for (uint32_t i = 0; i < x.size(); i++) {
|
||||
@ -121,56 +114,6 @@ real_t MLPPStatOld::chebyshevIneq(const real_t k) {
|
||||
return 1 - 1 / (k * k);
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::meanv(const Ref<MLPPVector> &x) {
|
||||
int x_size = x->size();
|
||||
const real_t *x_ptr = x->ptr();
|
||||
|
||||
real_t sum = 0;
|
||||
for (int i = 0; i < x_size; ++i) {
|
||||
sum += x_ptr[i];
|
||||
}
|
||||
|
||||
return sum / x_size;
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::standard_deviationv(const Ref<MLPPVector> &x) {
|
||||
return Math::sqrt(variancev(x));
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::variancev(const Ref<MLPPVector> &x) {
|
||||
real_t x_mean = meanv(x);
|
||||
|
||||
int x_size = x->size();
|
||||
const real_t *x_ptr = x->ptr();
|
||||
|
||||
real_t sum = 0;
|
||||
for (int i = 0; i < x_size; ++i) {
|
||||
real_t xi = x_ptr[i];
|
||||
|
||||
sum += (xi - x_mean) * (xi - x_mean);
|
||||
}
|
||||
return sum / (x_size - 1);
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::covariancev(const Ref<MLPPVector> &x, const Ref<MLPPVector> &y) {
|
||||
ERR_FAIL_COND_V(x->size() != y->size(), 0);
|
||||
|
||||
real_t x_mean = meanv(x);
|
||||
real_t y_mean = meanv(y);
|
||||
|
||||
int x_size = x->size();
|
||||
const real_t *x_ptr = x->ptr();
|
||||
const real_t *y_ptr = y->ptr();
|
||||
|
||||
real_t sum = 0;
|
||||
|
||||
for (int i = 0; i < x_size; ++i) {
|
||||
sum += (x_ptr[i] - x_mean) * (y_ptr[i] - y_mean);
|
||||
}
|
||||
|
||||
return sum / (x_size - 1);
|
||||
}
|
||||
|
||||
real_t MLPPStatOld::weightedMean(const std::vector<real_t> &x, const std::vector<real_t> &weights) {
|
||||
real_t sum = 0;
|
||||
real_t weights_sum = 0;
|
||||
@ -270,6 +213,3 @@ real_t MLPPStatOld::logMean(const real_t x, const real_t y) {
|
||||
}
|
||||
return (y - x) / (log(y) - std::log(x));
|
||||
}
|
||||
|
||||
void MLPPStatOld::_bind_methods() {
|
||||
}
|
||||
|
@ -10,24 +10,14 @@
|
||||
|
||||
#include "core/math/math_defs.h"
|
||||
|
||||
#include "core/object/reference.h"
|
||||
|
||||
#include "../lin_alg/mlpp_matrix.h"
|
||||
#include "../lin_alg/mlpp_vector.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class MLPPStatOld : public Reference {
|
||||
GDCLASS(MLPPStatOld, Reference);
|
||||
|
||||
class MLPPStatOld {
|
||||
public:
|
||||
// These functions are for univariate lin reg module- not for users.
|
||||
real_t b0Estimation(const std::vector<real_t> &x, const std::vector<real_t> &y);
|
||||
real_t b1Estimation(const std::vector<real_t> &x, const std::vector<real_t> &y);
|
||||
|
||||
real_t b0_estimation(const Ref<MLPPVector> &x, const Ref<MLPPVector> &y);
|
||||
real_t b1_estimation(const Ref<MLPPVector> &x, const Ref<MLPPVector> &y);
|
||||
|
||||
// Statistical Functions
|
||||
real_t mean(const std::vector<real_t> &x);
|
||||
real_t median(std::vector<real_t> x);
|
||||
@ -42,11 +32,6 @@ public:
|
||||
real_t R2(const std::vector<real_t> &x, const std::vector<real_t> &y);
|
||||
real_t chebyshevIneq(const real_t k);
|
||||
|
||||
real_t meanv(const Ref<MLPPVector> &x);
|
||||
real_t standard_deviationv(const Ref<MLPPVector> &x);
|
||||
real_t variancev(const Ref<MLPPVector> &x);
|
||||
real_t covariancev(const Ref<MLPPVector> &x, const Ref<MLPPVector> &y);
|
||||
|
||||
// Extras
|
||||
real_t weightedMean(const std::vector<real_t> &x, const std::vector<real_t> &weights);
|
||||
real_t geometricMean(const std::vector<real_t> &x);
|
||||
@ -62,9 +47,6 @@ public:
|
||||
real_t stolarskyMean(const real_t x, const real_t y, const real_t p);
|
||||
real_t identricMean(const real_t x, const real_t y);
|
||||
real_t logMean(const real_t x, const real_t y);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
#endif /* Stat_hpp */
|
||||
|
Loading…
Reference in New Issue
Block a user