Skip to content

itaipelles/rtacpy

Repository files navigation

rtacpy

PyPI Docs Tests Changelog License

A Python package for calculating RTAC, the rank-transform area coverage coefficient of correlation. This is the official repository of the paper (link TBD):

"A coefficient of correlation for continuous random variables based on area coverage"

Installation

Install this library using pip:

pip install rtacpy

Usage

import numpy as np
from rtacpy import calc_rtac, create_null_dist, area_coverage_independence_test
n = 100
x = np.random.rand(n)
y = np.random.rand(n)
null_dist = create_null_dist(n)
rtac, p_value = area_coverage_independence_test(x, y, null_dist=null_dist)
print(f'x and y are independent, rtac = {rtac}, p_value = {p_value}')
y = np.square(x)
rtac, p_value = area_coverage_independence_test(x, y, null_dist=null_dist)
print(f'x and y are dependent, rtac = {rtac}, p_value = {p_value}')

# If p_value is not needed, you can calculate just rtac
rtac_2 = calc_rtac(x,y)
assert rtac == rtac_2

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd rtacpy
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

python -m pip install -e '.[test]'

To run the tests:

python -m pytest

About

A Python package for calculating RTAC, the rank-transform area coverage coefficient of correlation.

Resources

License

Stars

Watchers

Forks

Languages