Hartigan's diptest.
Reason this release was yanked:
Bug in p-value computation when bootstrapping
Project description
diptest
A Python/C(++) implementation of Hartigan & Hartigan's dip test for unimodality.
The dip test measures multimodality in a sample by the maximum difference, over all sample points, between the empirical distribution function, and the unimodal distribution function that minimizes that maximum difference. Other than unimodality, it makes no further assumptions about the form of the null distribution.
Dependencies
numpy
- [Optional]
OpenMP
Parallelisation of the p-value computation using bootstrapping is offered using OpenMP.
OpenMP is disabled by default but can be enabled, see installation section
below.
Multi-threading can be turned off by setting the number of threads equal to 1. See the docstring of diptest
for details.
Installation
diptest can be installed from PyPi using:
pip install diptest
Wheels containing the pre-compiled extension are available for:
- Windows x84-64 - CPython 3.7 - 3.10
- Linux x84-64 - CPython 3.7 - 3.10
- MacOS x84-64 - CPython 3.7 - 3.10
- MacOS ARM-64 - CPython 3.8 - 3.10
If you have a C/C++ compiler available it is advised to install without the wheel as this enables architecture specific optimisations.
pip install diptest --no-binary diptest
Compatible compilers through Pybind11:
- Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or newer)
- GCC 4.8 or newer
- Microsoft Visual Studio 2015 Update 3 or newer
- Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)
- Cygwin/GCC (previously tested on 2.5.1)
- NVCC (CUDA 11.0 tested in CI)
- NVIDIA PGI (20.9 tested in CI)
Enable OpenMP
To enable OpenMP use:
CMAKE_ARGS="-DDIPTEST_ENABLE_OPENMP=ON" pip install diptest --no-binary diptest
Debug installation
To enable a debug build use:
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug" pip install diptest --no-binary diptest
Debug printing
To enable the debug print statements use:
CMAKE_ARGS="-DDIPTEST_ENABLE_DEBUG=ON" pip install diptest --no-binary diptest
then call the function with debug argument set to a value greater than zero:
diptest(x, debug=1)
Usage
This library provides two functions:
dipstat
diptest
The first only computes Hartigan's dip statistic. diptest
computes both the
statistic and the p-value. The p-value can be computed using interpolation of a
critical value table (default) or by bootstrapping the null hypothesis.
Note that for larger samples (N > 1e5) this is quite compute and memory intensive.
import numpy as np
import diptest
# generate some bimodal random draws
N = 1000
hN = N // 2
x = np.empty(N, dtype=np.float64)
x[:hN] = np.random.normal(0.4, 1.0, hN)
x[hN:] = np.random.normal(-0.4, 1.0, hN)
# only the dip statistic
dip = diptest.dipstat(x)
# both the dip statistic and p-value
dip, pval = diptest.diptest(x)
References
Hartigan, J. A., & Hartigan, P. M. (1985). The Dip Test of Unimodality. The Annals of Statistics.
Hartigan, P. M. (1985). Computation of the Dip Statistic to Test for Unimodality. Journal of the Royal Statistical Society. Series C (Applied Statistics), 34(3), 320-325.
Acknowledgement
diptest
is just a Python port of Martin Maechler's R module of the same
name.
The package wrapping the C implementation was originally written by Alistair Muldal.
The fork is an update with a number of changes:
- Fixes a buffer overrun issue in
_dip.c
by reverting to the original C implementation - Python bindings using Pybind11 (C++) instead of Cython
- P-value computation using bootstrapping has been moved down to C++ with optional parallelisation support through OpenMP
- Removed overhead caused by debug branching statements by placing them under a compile-time definition
- Added tests and wheel support
- C implementation of diptest was rewritten in C++ by Prodromos Kolyvakis
License
diptest
is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file diptest-0.4.0.tar.gz
.
File metadata
- Download URL: diptest-0.4.0.tar.gz
- Upload date:
- Size: 98.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc36ba5ecb07204e555a477586c6e35edbee9ecef70a90b8e529285b36b70268 |
|
MD5 | 12042521f4dc38091e8e95a440e70689 |
|
BLAKE2b-256 | 1998d4a7473bf66ca0b0bbc45360d486ef90b3c1be5466deb58637b252555aed |
File details
Details for the file diptest-0.4.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 97.2 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43bdfa31a21d605f351faafa4a05fa8b90bc2991d9c294339f8760e49132589f |
|
MD5 | ccc030007386af3bfcb0cb3ec68b0843 |
|
BLAKE2b-256 | 019cbfa575c35a5aa00989726a7a9ef7c45ad8411b1484d3e248508a9dc24e55 |
File details
Details for the file diptest-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 116.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc592ebc5313545a8ca88b7275d6826f519a9dc655865cc18125e367df687b16 |
|
MD5 | 83d30a4c5c429d14c9ef279525244ac4 |
|
BLAKE2b-256 | e2a65b388c4e32095edde85c5dd19f9e494f2025f1862e1ffd43e8003f331f95 |
File details
Details for the file diptest-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 86.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c83599403283e5c7f202181573c54483c74c183642e4e9eef175865ba2a75a60 |
|
MD5 | 8d76f9b7c23ca4d56c41fc2759a01c2f |
|
BLAKE2b-256 | fbdde33b9ed9905742020b4ef168bbeb67be7ca24544570e17b3a931486f5b04 |
File details
Details for the file diptest-0.4.0-cp310-cp310-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp310-cp310-macosx_10_13_x86_64.whl
- Upload date:
- Size: 90.0 kB
- Tags: CPython 3.10, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9680a098011dccf14ab03be563a9889c551e592acd8097a039f9ad48a098ac80 |
|
MD5 | 321a85c58ccc37bacb2e378bd60c2f3b |
|
BLAKE2b-256 | ca7a8636b94e34528affc4f6eace396c44366534c142c86dd4df5995ef8e0352 |
File details
Details for the file diptest-0.4.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 96.8 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ac41ac53d4bc19b442d8d010538c8fdf97d195cd25d75e235a2c69312bd8042 |
|
MD5 | 1007a06acf081aaae59505a2cb7773cb |
|
BLAKE2b-256 | 99ab48148d683a51f57105fc5f0d0e32d11d4c99e0c3a687bcb845f0c615dd63 |
File details
Details for the file diptest-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 116.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b085413132540f5496b2d8f9f5bf722ca161a5fc5689cf38a44dffb2f85f476 |
|
MD5 | 5e03a3ed6dae9c77cc62274e28c70376 |
|
BLAKE2b-256 | ca08cb2686a292121d1ad50ae055ee0095c4338df931989ad746649b322bfb34 |
File details
Details for the file diptest-0.4.0-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 86.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4b9a0ef2b88baae0e6aa91dc57a2c42824f294fdf7b9c41922c1848da692ed |
|
MD5 | c8f4dcde0f3abcff52e4f944f7dc6e16 |
|
BLAKE2b-256 | f56202f3826392d77dd9ab7ea4a5d5908ae4de5846dc2f3bcdd57f1f749eaf69 |
File details
Details for the file diptest-0.4.0-cp39-cp39-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp39-cp39-macosx_10_13_x86_64.whl
- Upload date:
- Size: 90.1 kB
- Tags: CPython 3.9, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3491b28507a19d4891ae17bbd6c5467931dac05b02c235f6338726383ae2e38d |
|
MD5 | a066eff896e435fa27015a38ac362b95 |
|
BLAKE2b-256 | 194915957aee65a9a10df9199409eeee1941bb9db56798ed7d517b6bd0c31015 |
File details
Details for the file diptest-0.4.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 97.1 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d102e71c6182ac30b7d0d2b6bd6283897145a777a7a81a4da5559655a347e975 |
|
MD5 | bff220744b16d74aa19c3b7d3b5d3541 |
|
BLAKE2b-256 | 169b9a70b00a834242305304ea98f44b79c94310d69659be1f1a8145319dfb39 |
File details
Details for the file diptest-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 116.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2482e49f10bbdba3e0d02dbc7838f86af76eaf170bb21b5d7e65b8f38c14952 |
|
MD5 | bb49b945dea49086f4ef641ffa5db260 |
|
BLAKE2b-256 | 7f993d541243075dfc4cf343a078bd30fe67e7d384ca5b10bfca63cc99373201 |
File details
Details for the file diptest-0.4.0-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 86.4 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d9db71da64f0e8adcbe6187913c2a2416fb396b8f465da8db5aa88e46e4f439 |
|
MD5 | 0e87b262a88f35dab02e01f1bf4d37b2 |
|
BLAKE2b-256 | 65a98f4d8985fdbabab90e6b751e939d6d3e6bf4914072e0d346d681c74cd1c8 |
File details
Details for the file diptest-0.4.0-cp38-cp38-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp38-cp38-macosx_10_13_x86_64.whl
- Upload date:
- Size: 90.1 kB
- Tags: CPython 3.8, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc3bf821d5176eeb93d4bd0872d02eb893d908f057056473356ef43569242942 |
|
MD5 | c733159efe9476430b3962f0168a002e |
|
BLAKE2b-256 | 9c69ce03195db51b73d3dc5d532d83b30f3756f417611e12e9e578118408c98d |
File details
Details for the file diptest-0.4.0-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 97.5 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5696bf0847cb681e2dbec9dd9ddb9c6885bed54d84942e80e137158f1109b24b |
|
MD5 | 8ff0e6bc22254eaf46dd2a21f8753d50 |
|
BLAKE2b-256 | 2a74875655bfe33adfddbcba32ebce9d46c40c45ac35a5b3dcd8903c4f27482a |
File details
Details for the file diptest-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 117.8 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0f3d6c3cfc0f997475155f7062734c3fc802e995c0b31373ce84719e40db32c |
|
MD5 | 04567d9c8a8728352f6ee6cc513ebc99 |
|
BLAKE2b-256 | 18341ba5e756e4170e72444a1c10e1073ffad3f2d37ed57f6df6b4cd2e035278 |
File details
Details for the file diptest-0.4.0-cp37-cp37m-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: diptest-0.4.0-cp37-cp37m-macosx_10_13_x86_64.whl
- Upload date:
- Size: 89.6 kB
- Tags: CPython 3.7m, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a39048c05cb890bc593eea19ad0f8d37897d2a3230e21544f947a1e38e1f8a5 |
|
MD5 | 14a1b99955a829f577d1929c2e43d02b |
|
BLAKE2b-256 | 675675bad7713c4bfa3730383f55236d609e7af42e2cc19fbd75a6778785b846 |