2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Chatterjee Correlation Coefficient (#770)

* Implement rank vector

[ci skip]

* Add documentation. Admittedly terrible.

* Add unit tests.

* Cleanup method of detecting if execution policies are valid or not

[ci skip]

* Implement and test chatterjee correlation

[ci skip]

* Add spot checks and special handling for constant Y

[ci skip]

* Add performance file

[ci skip]

* Add execution policy support to rank

[ci skip]

* Remove duplicates from v when generating the order vector

[ci skip]

* Fix macro error for use of <execution>

[ci skip]

* Use explicit types instead of auto to avoid warnings 

[ci skip]

* Add execution policy testing to rank

[ci skip]

* Add threaded implementation

[ci skip]

* Added threaded testing

* Fix formatting and ASCII issues in test

* Fix more ASCII issues

* refactoring

* Fix threaded impl

* Remove non-ASCII apostrophe

[ci skip]

* Doc fixes and add test comparing generally to paper values

* Significantly tighten tolerance around expected values from paper

* Change tolerance for sin comparison

Co-authored-by: Nick Thompson <nathompson7@protonmail.com>
This commit is contained in:
Matt Borland
2022-05-25 08:13:24 -07:00
committed by GitHub
parent 4d5cc6972e
commit e5eae18f14
13 changed files with 719 additions and 15 deletions

View File

@@ -0,0 +1,34 @@
// (C) Copyright Matt Borland 2022.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <vector>
#include <algorithm>
#include <boost/math/tools/random_vector.hpp>
#include <boost/math/statistics/chatterjee_correlation.hpp>
#include <benchmark/benchmark.h>
using boost::math::generate_random_vector;
template <typename T>
void chatterjee_correlation(benchmark::State& state)
{
constexpr std::size_t seed {};
const std::size_t size = state.range(0);
std::vector<T> u = generate_random_vector<T>(size, seed);
std::vector<T> v = generate_random_vector<T>(size, seed);
std::sort(u.begin(), u.end());
for (auto _ : state)
{
benchmark::DoNotOptimize(boost::math::statistics::chatterjee_correlation(u, v));
}
state.SetComplexityN(state.range(0));
}
BENCHMARK_TEMPLATE(chatterjee_correlation, float)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity()->UseRealTime();
BENCHMARK_TEMPLATE(chatterjee_correlation, double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity()->UseRealTime();
BENCHMARK_MAIN();