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.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


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

Uploaded Source

Built Distributions

diptest-0.5.2-cp311-cp311-win_amd64.whl (101.4 kB view details)

Uploaded CPython 3.11 Windows x86-64

diptest-0.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (120.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

diptest-0.5.2-cp311-cp311-macosx_11_0_arm64.whl (90.0 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

diptest-0.5.2-cp311-cp311-macosx_10_13_x86_64.whl (94.4 kB view details)

Uploaded CPython 3.11 macOS 10.13+ x86-64

diptest-0.5.2-cp310-cp310-win_amd64.whl (101.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

diptest-0.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (120.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

diptest-0.5.2-cp310-cp310-macosx_11_0_arm64.whl (90.0 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

diptest-0.5.2-cp310-cp310-macosx_10_13_x86_64.whl (94.4 kB view details)

Uploaded CPython 3.10 macOS 10.13+ x86-64

diptest-0.5.2-cp39-cp39-win_amd64.whl (101.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

diptest-0.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (120.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

diptest-0.5.2-cp39-cp39-macosx_11_0_arm64.whl (90.0 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

diptest-0.5.2-cp39-cp39-macosx_10_13_x86_64.whl (94.5 kB view details)

Uploaded CPython 3.9 macOS 10.13+ x86-64

diptest-0.5.2-cp38-cp38-win_amd64.whl (101.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

diptest-0.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (120.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

diptest-0.5.2-cp38-cp38-macosx_11_0_arm64.whl (89.9 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

diptest-0.5.2-cp38-cp38-macosx_10_13_x86_64.whl (94.4 kB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

diptest-0.5.2-cp37-cp37m-win_amd64.whl (102.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

diptest-0.5.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.3 kB view details)

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

diptest-0.5.2-cp37-cp37m-macosx_10_13_x86_64.whl (94.3 kB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: diptest-0.5.2.tar.gz
  • Upload date:
  • Size: 99.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for diptest-0.5.2.tar.gz
Algorithm Hash digest
SHA256 7f556a7873034322ea0357adc09f75054fc94dadfe6ff4fec90e9c166e823689
MD5 1f3f287a80f91d905620fc188227a122
BLAKE2b-256 ba7c895dc230a533d1f81362b1b070cde4684419906aa31da3acfcdcc1264e89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.5.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 101.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for diptest-0.5.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e6bbfa78e6f713b67a0a80ef6e3f06263ff6a493b3cce697db9b3f5c39ca7d52
MD5 5fed537d695b23d7a8203755577f83dd
BLAKE2b-256 0ee0af71c60e57c19432cd0b3ef5442729696656923c4ba3ec5e546e6287829f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f72e379c1aa673686593e7e02e42a6c4178232aa7d508eeacaa132c129ee621
MD5 8568edb90aba67a82584eed50f98dac4
BLAKE2b-256 63778aed702f2604487f2af217aa8ad8f4cd8a284a3469a28398f753681d8f84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2db5b4a97f425bbb0cc480c2baf865c2d6dec4b4b3e8d80d9ad2881004c1f22a
MD5 8851216851d79a66a136deb8fcbf3e5a
BLAKE2b-256 1cdf86b4bb43d1409f7ec3182b8bba938993179fa8e0a7b39025afee302def82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e51c098606f2a14333d1c1601190875da507ebf28fe1c0bc351b5846426d0353
MD5 649890777aba7cc3438c81615f6a5798
BLAKE2b-256 6f930f8d9f60ea7f6861cc1d23ec993782df847c4c78ec92be11933b70b2c920

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.5.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 101.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for diptest-0.5.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5beaafb5bc9f865a5e4bbee4cc6716dabd5b35e72245c6bdc6019a316bf394ba
MD5 2cb178588eaf4eabc1ea06258f9745ab
BLAKE2b-256 ed128540f5683dfe9000c19abecce8efc9aef3722ef5fee79122ec6cd3f20e9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de1db15900bb75846829dbb59396caa56523677bad273aa14ac81e71cc16741b
MD5 1878ed941f04e5a5693beb6fa7ee51f0
BLAKE2b-256 7835e3523f38e13a20e274ec49fc9cc57eac7d9704a1716af2f194883249a983

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa02f13bff542a84f3c0cc034c35091988bf54e2ad7a3e94ef7359961c24530c
MD5 211245d775fe32d7b71eb0c359897a67
BLAKE2b-256 3f2fe1068ca34346f41446f00a3ef6676ccb557cc58b29e0d836cbed41e7283d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d184768b677329232611f1e05ea5c81cde40081a5c511d8dddf4eaf8529b73fb
MD5 57163fb55bdc693cbb0bd03676584bc5
BLAKE2b-256 d85f41814e02b45e63b0e83fc5ccf30a6d822642acd26c6d2a854f8a84528081

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.5.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 101.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for diptest-0.5.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 dbb80010822c0f57411eddd2d3c5e8ecbbc1f8217e9b1e750990c4910ecd1817
MD5 6314ab0508a1debf23e42b47cd4e5935
BLAKE2b-256 e6a8295ec23291b43ffeef2966976db0a80df5e328ee407df1d30ca8cea0928d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 547d6d9192c245b4942e6038bca3312b69324d7178fa6e1b8db7efa030b16ee3
MD5 28c1f268f418268c8785720fb78f4912
BLAKE2b-256 8b09c08a4638134f1ad9024ef82db3536588f8228a5edf5554fc1b6c58bc84d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 436bccc4a2f2e236a8c71c551364ff2683be4d2c3d2fca55fc7048fd2e28235b
MD5 7681930a3f2b48f143dedda7c7ccf957
BLAKE2b-256 6ceb55d8b32e8e5bd47f0a36b92eb421db2bc67e28fc63502233e0dd21c3db4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 61a6cf3063d14c7a5b147db46161f7d091c31a0c8b8a88cdbf7ff5c368733d0e
MD5 a96ca4e7a3ecd7784c51f4648ec34ae0
BLAKE2b-256 2567ab90716b0bebc047baa83fc58f4466ec099cf4cf218fcf34846ac7ce46be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.5.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 101.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for diptest-0.5.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 275718fa858b74e90f106edf7808a7527b64c274dcd02ae3ef6f9905238d189f
MD5 df07a69c4cfad8d43b7185962c0b3381
BLAKE2b-256 66eab56d1bf3956b3fec8e0ad3c1f278fa95869d8a7cae876f065b0df9f94e65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 252a1d0da05acc28cb4ef6b4a6bea943b294beee5d8a254cd040d03b9077a2f3
MD5 f93dfe3c0e0e5bfe9394d687f6976f21
BLAKE2b-256 a8e8b8d234ac08b0716e5bb9d4d34bca97e127f3defde39cd13def1d87c3472d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03a09d47969d7f167c4ccd0a1345799566a6c467e166c6be8b1bf1e0f8a28463
MD5 fd59a90a55c64f0df5119bf13249cf53
BLAKE2b-256 fc6690ef8f648a7091d74372dbb56c0f037c45eecf363becbd742b1de0fe520b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 aa01fd90bdac2d58b169d8ff90cadc4fd495a55992dce4dff29f1d0fbdb189df
MD5 f2962bb3d6f895818c07ecb196f78068
BLAKE2b-256 ef82575f345f4ce1e6de4bd066d6c5012a64e2eb28f82b1e96cd6143db92db24

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for diptest-0.5.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2b8332fafa38f4df2ed5e3b77fa702a9df369d3a170241aa7c76b3eb8dddaff4
MD5 1817adc4a55841931a177190f38677d2
BLAKE2b-256 de183a978ceb73d8b49f5e004772f547972450021680b737330de89fa6f7bb50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c31320e050d8789942a71503c98154631fe9eaef2c7a47651899e0587f5fa398
MD5 ef54fbd92f630c28f0493e0ea36935da
BLAKE2b-256 d7c6b4f34fc8af40de25faa2299de37320ba45737606cd3c7a99b69b554936c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.5.2-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 af080b790e06fb421ebb155761b23e6fe684534e851bcce75b9785545da2d783
MD5 44f42d6d91eed1367ee49c2dd4eb1f24
BLAKE2b-256 d08013c628ab5031f3719faeca4ffe272fd15f786639bca3b7687c66190da679

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