GithubHelp home page GithubHelp logo

wdm's Introduction

wdm

build status License: MIT

A header-only C++ library for weighted dependence measures

Provides efficient implementations of weighted dependence measures and related independence tests:

  • Pearsons's rho
  • Spearmans's rho
  • Kendall's tau
  • Blomqvist's beta
  • Hoeffding's D

All measures are computed in O(n log n) time, where n is the number of observations.

Functionality

The library provides:

  • a function wdm() to compute the weighted dependence measures,
  • a class Indep_test to perform a test for independence based on asymptotic p-values.

For details, see the API documentation and the example below.

Dependencies

The library only requires C++11.

For projects already using the Eigen linear algebra library, there are convenience wrappers that can be made available via

#include <wdm/eigen.hpp>

Including the library in other projects

There are two options:

  1. Either copy the header files in include/ to your project.
  2. Install the headers globally using the CMake project. To do that go to the root repository of this repo and run:
    mkdir build && cd build         # open build folder
    cmake .. && sudo make install   # install library
    cd .. && rm -rf build           # leave and remove build folder
    To use the library in your project, just add target_link_libraries(your_proj_name wdm) to your_proj_name/CMakeLists.txt.

You can then include the main header in your source code:

#include <wdm.hpp>

Example

#include "wdm.hpp"

// input vectors
std::vector<double> x{1, 3, 2, 5, 3, 2, 20, 15};
std::vector<double> y{2, 12, 4, 7, 8, 14, 17, 6};

// weights
std::vector<double> w{1, 1, 2, 2, 1, 0, 0.5, 0.3};

std::cout <<
    "unweighted Kendall's tau: " << wdm::wdm(x, y, "kendall") << std::endl;
std::cout <<
    "weighted Kendall's tau: " <<  wdm::wdm(x, y, "kendall", w) << std::endl;

// weighted independence test
wdm::Indep_test test(x, y, "kendall", w);
std::cout << "statistic: " << test.statistic() << std::endl;
std::cout << "p-value: " << test.p_value() << std::endl;
unweighted Kendall's tau: 0.2965
weighted Kendall's tau: 0.550633
statistic: 1.71047
p-value: 0.0871793

wdm's People

Contributors

tnagler avatar tvatter avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

wdm's Issues

unused variables warnings

Scanning dependencies of target gtest
[ 25%] Building CXX object googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 50%] Linking CXX static library ../../lib/libgtest.a
[ 50%] Built target gtest
Scanning dependencies of target test_all
[ 75%] Building CXX object test/CMakeFiles/test_all.dir/test_all.cpp.o
In file included from /home/slayoo/devel/wdm/include/wdm.hpp:11,
                 from /home/slayoo/devel/wdm/test/test_all.cpp:10:
/home/slayoo/devel/wdm/include/wdm/prho.hpp: In function ‘double wdm::impl::prho(std::vector<double>, std::vector<double>, std::vector<double>)’:
/home/slayoo/devel/wdm/include/wdm/prho.hpp:45:45: warning: unused variable ‘wi_sq’ [-Wunused-variable]
     double v_x = 0.0, v_y = 0.0, cov = 0.0, wi_sq;
                                             ^~~~~
/home/slayoo/devel/wdm/test/test_all.cpp: In function ‘int main(int, char**)’:
/home/slayoo/devel/wdm/test/test_all.cpp:13:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
 int main(int argc, char **argv) {
          ~~~~^~~~
/home/slayoo/devel/wdm/test/test_all.cpp:13:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
 int main(int argc, char **argv) {
                    ~~~~~~~^~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.