diff --git a/rogueviz/sag/functions.cpp b/rogueviz/sag/functions.cpp index e7420d2f..0cb1d2f1 100644 --- a/rogueviz/sag/functions.cpp +++ b/rogueviz/sag/functions.cpp @@ -182,7 +182,7 @@ void optimize_sag_loglik_logistic() { void optimize_sag_loglik_match() { if(state &~ SS_WEIGHTED) return; - lsq::leastsquare_solver<2> lsqs; + stats::leastsquare_solver<2> lsqs; for(auto& ei: sagedges) { ld y = sagdist[sagid[ei.i]][sagid[ei.j]]; diff --git a/rogueviz/som/measures.cpp b/rogueviz/som/measures.cpp index 76c651f8..a403220e 100644 --- a/rogueviz/som/measures.cpp +++ b/rogueviz/som/measures.cpp @@ -2,47 +2,11 @@ // Copyright (C) 2011-2022 Tehora and Zeno Rogue, see 'hyper.cpp' for details #include "kohonen.h" +#include "../statistics.cpp" namespace rogueviz { namespace measures { -double kendall(const vector>& allp) { - int maxo = 0, maxe = 0; - for(const auto& a: allp) maxo = max(maxo, a.first), maxe = max(maxe, a.second); - maxo++; maxe++; - - if(maxo >= 256 || maxe >= 256) { - println(hlog, "more than 256!\n"); - exit(1); - } - int cnt[256][256]; - for(int a=0; a counts(maxe, 0); - vector totals(maxe); - double tau = 0; - for(int i=0; i> recreate_topology(const vector& mapp, const vector >& edges) { auto cmapp = mapp; @@ -117,7 +81,7 @@ ld evaluate_measure(manidata& emb, manidata& orig, vector& mapp, vector(allp); } else if(k == 3) { vector empty(Ne, true); diff --git a/rogueviz/statistics.cpp b/rogueviz/statistics.cpp index 2d735b1c..17cd9cf7 100644 --- a/rogueviz/statistics.cpp +++ b/rogueviz/statistics.cpp @@ -1,9 +1,12 @@ +#ifndef _STATISTICS_CPP_ +#define _STATISTICS_CPP_ + #include #include #include #include -namespace lsq { +namespace stats { using namespace std; @@ -98,4 +101,41 @@ template struct leastsquare_solver { } }; +template double small_kendall(const vector>& allp) { + int maxo = 0, maxe = 0; + for(const auto& a: allp) maxo = max(maxo, a.first), maxe = max(maxe, a.second); + maxo++; maxe++; + + if(maxo >= dim1 || maxe >= dim2) + throw hr::hr_exception("small_kendall limit exceeded"); + int cnt[dim1][dim2]; + for(int a=0; a counts(maxe, 0); + vector totals(maxe); + double tau = 0; + for(int i=0; i