Skip to main content

Hartigan's diptest.

Project description

diptest

Linux Build Windows Build MacOS build PyPi

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.12
  • Linux x84-64 - CPython 3.7 - 3.12
  • MacOS x84-64 - CPython 3.7 - 3.12
  • MacOS ARM-64 - CPython 3.8 - 3.12

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:

    SKBUILD_CMAKE_ARGS="-DDIPTEST_ENABLE_OPENMP=ON" pip install diptest --no-binary diptest

Debug installation

To enable a debug build use:

    SKBUILD_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug" pip install diptest --no-binary diptest

Debug printing

To enable the debug print statements use:

    SKBUILD_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diptest-0.7.0.tar.gz (98.0 kB view details)

Uploaded Source

Built Distributions

diptest-0.7.0-cp312-cp312-win_amd64.whl (100.0 kB view details)

Uploaded CPython 3.12 Windows x86-64

diptest-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (123.8 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

diptest-0.7.0-cp312-cp312-macosx_11_0_arm64.whl (90.6 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

diptest-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl (94.7 kB view details)

Uploaded CPython 3.12 macOS 10.13+ x86-64

diptest-0.7.0-cp311-cp311-win_amd64.whl (100.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

diptest-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (125.1 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

diptest-0.7.0-cp311-cp311-macosx_11_0_arm64.whl (92.7 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

diptest-0.7.0-cp311-cp311-macosx_10_13_x86_64.whl (97.4 kB view details)

Uploaded CPython 3.11 macOS 10.13+ x86-64

diptest-0.7.0-cp310-cp310-win_amd64.whl (100.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

diptest-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (123.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

diptest-0.7.0-cp310-cp310-macosx_11_0_arm64.whl (91.4 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

diptest-0.7.0-cp310-cp310-macosx_10_13_x86_64.whl (96.1 kB view details)

Uploaded CPython 3.10 macOS 10.13+ x86-64

diptest-0.7.0-cp39-cp39-win_amd64.whl (100.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

diptest-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (123.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

diptest-0.7.0-cp39-cp39-macosx_11_0_arm64.whl (91.4 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

diptest-0.7.0-cp39-cp39-macosx_10_13_x86_64.whl (96.1 kB view details)

Uploaded CPython 3.9 macOS 10.13+ x86-64

diptest-0.7.0-cp38-cp38-win_amd64.whl (99.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

diptest-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (123.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

diptest-0.7.0-cp38-cp38-macosx_11_0_arm64.whl (91.3 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

diptest-0.7.0-cp38-cp38-macosx_10_13_x86_64.whl (96.0 kB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

File details

Details for the file diptest-0.7.0.tar.gz.

File metadata

  • Download URL: diptest-0.7.0.tar.gz
  • Upload date:
  • Size: 98.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for diptest-0.7.0.tar.gz
Algorithm Hash digest
SHA256 5a1b38ab87ce2b1e563ba088a490849db830587d23631b30bb8e48264f7768f7
MD5 0bab78dce2d1c69def8ab280814e509d
BLAKE2b-256 6e8cf4b008e3f7b026624e4739bac344cfd8c4bd6b6389b869ba5808790d1b9e

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: diptest-0.7.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 100.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for diptest-0.7.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 47bbd542bececd36999316402aa5f478cd4551110f54e40f099a71b03110a73d
MD5 6e8b9e8aa589559c7a82b2dfe3b95a05
BLAKE2b-256 8b6d606af5dd26d1b947dd16c8d0c92930eb813c70ffd048c3071bbc944f86f4

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9544b79afb9496cb5c2013a5bfb0c423672ee14ea1db22aae7737051ece289dc
MD5 9128a07de6afb0cc8aea997edc3da808
BLAKE2b-256 0221d2a223404d6b7c85ea2614e10a3d32431b5fd144d636cf680b4ab845a92f

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e85692a9b3025054a88db44c917ee59c465091000fc857cd068d2ab4c262655
MD5 1429ab939be56ac58902290992bd1c07
BLAKE2b-256 74c9857fa24cf656f4085b2bebb2c37cfef0000ea1b0868b7fd1b638cd0e5d97

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9853cce7bb3f922c222539bd7836c0cbafde97785d76d94e0de5126361d9a1c0
MD5 2896b85f9483f8289837fe985ffa2cfe
BLAKE2b-256 8ad135dfd59d005a2400b82d6d1ce40e211cc9599384177902c2a7762f7bcb31

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: diptest-0.7.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 100.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for diptest-0.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e495a4f1fbd8085290a0eff50813da6471b1382c4acd0837aeb7722545b01c8c
MD5 d0be93e4b034a1ae68b76215107a4d96
BLAKE2b-256 7f09afdceaccf3e22982f21d1ee1d8315f4ca03b8c0f0efe6febb62767473581

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 97d448f45b4576638d76e1c19bf5333c610b46f38aa313cfcbb8e250d931dc5c
MD5 6dc2935414af78a754d75790fdb0e4ea
BLAKE2b-256 490b665acbcffea92973fe2d1cf8becb1f66d101f9b0c6a606a1843b0f42720b

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e33bc24a3b52e64a4553ef6eb0632d767c93aee1db176e12b659ef61cede399
MD5 158ea06073c463cd059bc29daf6991c2
BLAKE2b-256 c5c406708f1231129d924ebd7404eaded652e163acc30ef45905a4ded60079c6

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9395745fe8be103f062120459265f609f7cd3ee7ae0a5052e0111f18d1636737
MD5 5798b3e5ca80188e65292a2d4e7936b9
BLAKE2b-256 bc6cf77073652f74fa4ab0003bf64d897a79aaa43c706763d9b63a4fbe8e3475

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: diptest-0.7.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 100.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for diptest-0.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cacaaa03aed69fb5bb5ef6e47b2c123f3304a56113a1cb233702d62a010b6def
MD5 beeac4a60df0bc7b87227e3227986f06
BLAKE2b-256 b2ee538e746da4bc37ea238c0f66efec779cefbb35657861f3701c9e9cca0e0d

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ab87bf26d1c408eca8733a8786f07cfc84400cf6c10fbfb3bc0e29eb7946f19
MD5 344a6b3802b2a9c7f23e30534c860b2b
BLAKE2b-256 64537f2d24e1e5c26b7bab38f171d6147135bed14c0e6946350cc70fada04fa8

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35c1a7bf9eab0ab49aa6a6965ab0739fc859a268499db95e091d71a356a11a8b
MD5 477f796a63b20224d388c603aa54a7d5
BLAKE2b-256 b367ced261f5d9fa630bafd7f42cc13d0afe36f9070b29724ef0f28a704a0b74

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 85477d5c74c4235713e20182a7140f21f93b2e0b3a8531341947496c24d68bec
MD5 0c17fa59336a28e97507f97bd5d93674
BLAKE2b-256 feb0ba0d07a837678a8d68602a9e25a6fcc440b5a4f75e4c3c369d26b8758ceb

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: diptest-0.7.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 100.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for diptest-0.7.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 53025637a81ce26061c572204c66dcbd90fcb6b32cba16539fd52d37e2a56f2d
MD5 6885ac52534b8cac836e6ca9d3bccf8f
BLAKE2b-256 988b567d3b4addc4647ea0a295c3eb2d9f4621c69262abda814b58ab5c8ccf2f

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff159a795f3d14958233f2a29abb35d556e0200c300913029933deaf4b141eca
MD5 f4017e6f6177132001ff3a92a243f169
BLAKE2b-256 bd030890841404898f19311039c2034a5c85b4203a0972c27d834b126a7ae275

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 742f18c90684cbe1445f5e5a54332320e0896714e0ed13e5a90f6f2a1dd4525f
MD5 0488204e52ea64a01502dbe3fbd68fa8
BLAKE2b-256 6f23c37d724518f879d93500c79793a913d3d6d62c09bf0b466bccfa7158ac42

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp39-cp39-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3860769e325cebab2a848118fa773d4cd6abb1c1aa4d423ded2edb1214ed91e1
MD5 2dafec389b334569942833e695229d1d
BLAKE2b-256 85b2409571ca8224e698d65655523edf85ece215dea7660b2b2e4ebef28b0235

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: diptest-0.7.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 99.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for diptest-0.7.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cd0332329bf8726c15f8a2fa46b0e69d898c988fe4afae43aadca685f059bf00
MD5 940b7e580c76dda610b5bca4e417253d
BLAKE2b-256 e2f33f16757a30aae1ac075198ac0cba59ae835887c8eae1778991443a5b8790

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1967daa25c5a4cec5880f51cfb9c1ff5b8b719b10cfdd603e764ed48af045977
MD5 def2d0bc91dc4af82271c929ac2d595d
BLAKE2b-256 b9afae76473a5e20aac8c7bd8de2d5322cbbee92cb693af4587a9d9b995a4195

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ad71f77563570b252cd89ba8f647531030f1f3f5511add09896a0aee62faf0d
MD5 e2bc88239c46a2e35f4d1ad3ca699984
BLAKE2b-256 ed95c1855525c5317033c56ba7cccd408e881eb6686e349870fe88ff520a491d

See more details on using hashes here.

File details

Details for the file diptest-0.7.0-cp38-cp38-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.7.0-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 781fa14dc1c6fef393f371ac041c1acf6fd1b5c4d518f085458ac97afea7ef9e
MD5 5a2a178897e444be2a8158af9d969cbb
BLAKE2b-256 47012a9a0d3645d107358b6442f4482845608e81a4340d25af43a4abf31d662c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page