Python code of independence test algorithm proposed in
Kernel‐based tests for joint independence
Niklas Pfister, Peter Bühlmann, Bernhard Schölkopf, Jonas Peters
Journal of the Royal Statistical Society: Series B (Statistical Methodology) 80.1 (2018): 5-31.
- numpy (=1.13.3)
- scipy (=1.1.0)
- statsmodels (=0.10.1)
We test the code using python 3.6.8 on Windows 10. Any later version should still work perfectly.
After installing all required packages, you can run demo.py to see whether dhsic
could work normally.
The test code does the following:
- generates 100 instances (a (100, 3) numpy array) from 3 jointly independent variables;
- applies
dhsic
joint independence test on the data - changes variable 3 to be dependent on variable 1 and 2
- applies
dhsic
joint independence test on the updated data.
from dhsic import dhsic_test, dhsic
res = dhsic_test(X) # conduct joint independence test
res = dhsic(X) # compute the dHSIC value
Function dhsic_test()
Argument | Description |
---|---|
X | matrix of all instances, (n_samples, n_vars) numpy array |
alpha (optional) | level of the test |
method (optional) | method of the test |
Output | Description |
---|---|
res | dictionary containing test statistic, critical value, p-value and the name of the test method |
Function dhsic()
Argument | Description |
---|---|
X | matrix of all instances, (n_samples, n_vars) numpy array |
Output | Description |
---|---|
dHSIC | dHSIC value |
- Shoubo Hu - shoubo [dot] sub [at] gmail [dot] com
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.