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

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


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.6.0.tar.gz (100.0 kB view details)

Uploaded Source

Built Distributions

diptest-0.6.0-cp311-cp311-win_amd64.whl (99.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

diptest-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (123.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

diptest-0.6.0-cp311-cp311-macosx_11_0_arm64.whl (91.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

diptest-0.6.0-cp311-cp311-macosx_10_13_x86_64.whl (96.3 kB view details)

Uploaded CPython 3.11 macOS 10.13+ x86-64

diptest-0.6.0-cp310-cp310-win_amd64.whl (99.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

diptest-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

diptest-0.6.0-cp310-cp310-macosx_11_0_arm64.whl (90.3 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

diptest-0.6.0-cp310-cp310-macosx_10_13_x86_64.whl (95.0 kB view details)

Uploaded CPython 3.10 macOS 10.13+ x86-64

diptest-0.6.0-cp39-cp39-win_amd64.whl (99.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

diptest-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

diptest-0.6.0-cp39-cp39-macosx_11_0_arm64.whl (90.3 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

diptest-0.6.0-cp39-cp39-macosx_10_13_x86_64.whl (95.1 kB view details)

Uploaded CPython 3.9 macOS 10.13+ x86-64

diptest-0.6.0-cp38-cp38-win_amd64.whl (98.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

diptest-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

diptest-0.6.0-cp38-cp38-macosx_11_0_arm64.whl (90.2 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

diptest-0.6.0-cp38-cp38-macosx_10_13_x86_64.whl (95.0 kB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

diptest-0.6.0-cp37-cp37m-win_amd64.whl (99.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

diptest-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.4 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

diptest-0.6.0-cp37-cp37m-macosx_10_13_x86_64.whl (94.9 kB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for diptest-0.6.0.tar.gz
Algorithm Hash digest
SHA256 cbb8bd8619773974920cb6eea1a926ca5d67eef3b0ec2d1107bd44db61fb45b1
MD5 020b3d17d2eeabab1ee259365ee28cf9
BLAKE2b-256 55bb018197a8acedd439573ff6219622bd84cbbfcc464e24e418e0d9a749a353

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for diptest-0.6.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 60f08c0a08e37d9138f2d54235c67381366e9b6500ebf8b9959660a265772ef1
MD5 6d695cc9c128d5dbbda38030cc9aed78
BLAKE2b-256 eb2c85f2664dd0bc353acafaa56b329f666414c1f76aef367d9b56d567443ddc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f87cd310618f0fbe7bc90e7fb9749a28620c10ace2a4a75cea0919123eb8f1b2
MD5 6bd75d3c9a3ea7f3d290d067960032a4
BLAKE2b-256 91762c8027197ae896b97238a935dbded0bfdede14892de90176f915cd994091

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78171bb0baa666dbc22cc9d171d7f07f130a959401af3deaa0d3878954d85b29
MD5 51298402b9aebf1d2a9d2fb828bd5862
BLAKE2b-256 fd2a1becbe65b7697a08e90a751b51fc08ae26b6b45442e4e1afe7fba10ab5f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 64851f1a3c2b0d58f7193938aaefec3f137c59f54c327dcf31847fb63ba84f9e
MD5 a60902497c3aad0e2132408a295d817e
BLAKE2b-256 75bfb52f0215178d309809017c6805275777ddb69589a99c47d21eb08973ce6c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for diptest-0.6.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 765fbbf04d7f37700e746b39d1da25273173e8244fe001d1ce36e678aa385432
MD5 9cf736cc8bbc047dbe2bbb5b783eabb9
BLAKE2b-256 eb26180e67ee63550fc3794389118f53fc370f48b0eb802c6d46decfd902d1b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a864d96ac1411d50ae680350ad7cc993459379036ade7613b4d003ce89d4d50
MD5 0ff80651ee86a0b97fa67ae3a630cfc6
BLAKE2b-256 9864b9573c801174d4064d3322bc4c22dd2ea92bc6a3f2084838e1fa72c81a28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9dd54198bea8721f1754d4d48560566e81aec9277756861c1873ace08299af63
MD5 a52cabc6701f164fbd51db3aee841a6e
BLAKE2b-256 5d4d702bd8aea8dd7282cb8c58512d952eea719220cd9f60d6079f471ffc8cd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e32ea9e876b6d6843407982eaffe35a0e0b1d92a852db1599bba1c088626879c
MD5 2eafcd0597587fa1be8128746c9f3370
BLAKE2b-256 e5d9ef6f0003382161dca74162254ba181cd58e806b45a0443db0a1ba2acb049

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for diptest-0.6.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5e1a99fcaf7cd04bdc0529af246c2360f058200e66c4a8f08e007dea10854816
MD5 dd085099a32ff80f0da3645a90a4af85
BLAKE2b-256 a8e266d6053d6966dd0a81b0e43ce796f0fedc726219280f7bd7658fd72e1fe8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc0d209b12ae444e986a7f7252db8c795907ee92b682f23a6e0e52fd874c60d2
MD5 9be419b69a677b6eaefc53d64590c1d8
BLAKE2b-256 fec9634b7709c7d22ac6c5970db58b6230a4822fef38e69b5c576d086da7bc1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd8c32f26afce021508e3d38d5cc1deb75e4d43cfce4e5555a78d292762f00c5
MD5 74671ecc381b4808e633a18cc89c8a3b
BLAKE2b-256 13270cd8137898f6226322d7fc14714aa2b93ec3c253fa2b5de7ccb7cec3d066

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1c3d75e1fdcba0d5bfae51210549ae65a2003349af232469989b86b8bf8114b3
MD5 bfcd9433fd1ff4af1c9ca78badeb7a5a
BLAKE2b-256 919ae41a0474ccf69854f4251aff5a6955e266a86f124f2319d5d092cdac0c73

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for diptest-0.6.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9a6540fece9ea0473401185dd738f027c865f499911a2a03e35c52f1422daa55
MD5 26bfcb17144a0d464a65a055dbcf490a
BLAKE2b-256 762eaad5994cca35827cc03f87c6442bfdf921aed2007c00723f0779b8c187de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0dc95dbd5cffbc2ee32505ee5b4bca4b5f9273d9ab9a595ae329f3bb802af576
MD5 6fbbd8202ebdf5c2530ea5559b6437c2
BLAKE2b-256 84b2b3ccd3594a69f9dc0dc47373c6d310d18e618b842b397d2a2b8fffa79c31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23b08f41c55a6643c47d78dd2f2e77c72283cf718bf2162896a9a619c05c5362
MD5 c999e17f2d7e37dd5df8456853ae5850
BLAKE2b-256 d15a76ed2a8e65c4745d042f3cd80965985a19afc0ccf12e4eca97e9fd9ac47d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.0-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 55865e92d72693bfd4eeac37c020325c98b6ba75aaef0c4a084f8e281adbb5f3
MD5 9c6a330e246b1b89b5abec4899bb83e3
BLAKE2b-256 4ba97c56dea34cfb06651f7d1d3bb4c1052137497df81ff8f5cb3ac42df06f31

See more details on using hashes here.

File details

Details for the file diptest-0.6.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: diptest-0.6.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 99.8 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for diptest-0.6.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 77251b35386336136fa9cad2b49e7936f7aee70d66a99761803f69754b0a37a1
MD5 0c7ca031afa460385ba0a11cf38d4bc8
BLAKE2b-256 d10e987b663b97a8e1b58b8bdb5b52c00b66f45a36b7da6724fdb2fd8d3d5dea

See more details on using hashes here.

File details

Details for the file diptest-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11eb8864d37bd85363f113aece24565936c735181a71fff9ac223b035d973c44
MD5 c7ffc633603eddf969ea6a472203586f
BLAKE2b-256 3a4c6b225e3c41e74a5c28fbb0f052b5ea9f951cd1d596700c8ac79b92f49899

See more details on using hashes here.

File details

Details for the file diptest-0.6.0-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for diptest-0.6.0-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f0527a0088b3b049a4222c5f8bf01dc03079e904ed3eff4486b6ee41ccacf13e
MD5 7117d49e8202d56961ec94d6c721430a
BLAKE2b-256 d249bc6c1c3e3c634ed944a4fdf0b02c83c6b5ce62c72921f249c15b92638f45

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