diff --git a/rogueviz/statistics.cpp b/rogueviz/statistics.cpp index 5423d8e0..633cac3a 100644 --- a/rogueviz/statistics.cpp +++ b/rogueviz/statistics.cpp @@ -136,6 +136,58 @@ template double small_kendall(const vector>& return tau / par; } +template double kendall(vector> allp) { + int maxx = 0; + for(const auto& a: allp) maxx = max(maxx, a.first); + maxx++; + + vector counts(maxx, 0); + vector totals(maxx, 0); + + double tau = 0; + sort(allp.begin(), allp.end(), [] (auto a, auto b) { return a.second < b.second; }); + + auto last = allp[0].second; + vector to_add; + for(const auto& a: allp) { + if(a.second != last) { + for(auto ad: to_add) { + totals[ad]++; + for(int x=ad+1; x> p = { {1,1}, {2,2}, {3,3}, {4,4} }; + println(hlog, "p = ", stats::kendall(p)); + + vector> q = { {1,1}, {2,2}, {3,3}, {4,3} }; + println(hlog, "q = ", stats::kendall(q)); + + vector> r = { {1,1}, {2,2}, {3,4}, {4,3} }; + println(hlog, "r = ", stats::kendall(r)); + + vector> s = { {1,1}, {2,2}, {3,3}, {3,4} }; + println(hlog, "s = ", stats::kendall(s)); + } + } +#endif } #endif