Giter VIP home page Giter VIP logo

ndtest's Introduction

ndtest

Multi-dimensional statistical tests with python

  • 2D Kolmogorov–Smirnov test (KS test)
  • 1D and 2D energy distance statistics test

Citation

The code has been cited in ~40 papers according to Google Scholar 🤩

If you used this code in your paper, I would be grateful for a simple footnote mentioning the author and URL of this repo, such as

We perform the 2D Kolmogorov–Smirnov test ...
using the public code \textsc{ndtest}\footenote{Written by Zhaozhou Li, \url{https://github.com/syrte/ndtest}}.

As to references for the algorithms, please check the docstrings.

Installation

pip install git+https://github.com/syrte/ndtest

Usage example

import numpy as np
import ndtest

# generate mock samples for the test
np.random.seed(42)
x1, y1 = np.random.randn(2, 100)
x2, y2 = np.random.randn(2, 100)  # same distribution as (x1, y1)
x3, y3 = np.random.randn(2, 100) * 1.5 + 0.5  # different distribution from (x1, y1)

# 2D KS
P, D = ndtest.ks2d2s(x1, y1, x2, y2, extra=True)
print(f"{P=:.3g}, {D=:.3g}")
# P=0.219, D=0.17

P, D = ndtest.ks2d2s(x1, y1, x3, y3, extra=True)
print(f"{P=:.3g}, {D=:.3g}")
# P=2.36e-05, D=0.385  # very small P, as expected.

See the docstring for the detailed usage and explanation.

ndtest's People

Contributors

syrte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ndtest's Issues

Passing input to ks2d2s

Can you please share an example on how to pass the input. On passing two 2D matrices, I am getting the error: TypeError: ks2d2s() takes at least 4 arguments (2 given).

Changing ks2d2s to estat2d raises an error

Hello!

Thanks a lot for python implementation of 2D KS test, it is really helpful!
I also tried to use estat2d, but seems it does not work even for the example given on main page.
Changing ks2d2s to estat2d:

# generate mock samples for the test
np.random.seed(42)
x1, y1 = np.random.randn(2, 100)
x2, y2 = np.random.randn(2, 100)  # same distribution as (x1, y1)

p,en,en_boot = estat2d(x1, y1, x2, y2)
print(f"{p=:.3g}")

raises an error:

    p = (en_boot >= en).sum() / nboot

TypeError: '>=' not supported between instances of 'float' and 'NoneType'

UPD: It was wrong from my side. The function is actually working.

license?

I just found your code. Thanks for sharing it!

I would like to use it, but you don't have a license in the repo. Could you please add a license?

p value

Hello,
can you please explain, what is the meaning of p value as output of ks2d2s ?
Thanks.

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.