Skip to main content

Hartigan's diptest.

Reason this release was yanked:

Bug in p-value computation when bootstrapping

Project description

diptest

Linux Build Windows Build MacOS build

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

Uploaded Source

Built Distributions

diptest-0.4.1-cp310-cp310-win_amd64.whl (97.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

diptest-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (116.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

diptest-0.4.1-cp310-cp310-macosx_11_0_arm64.whl (86.8 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

diptest-0.4.1-cp310-cp310-macosx_10_13_x86_64.whl (90.4 kB view details)

Uploaded CPython 3.10 macOS 10.13+ x86-64

diptest-0.4.1-cp39-cp39-win_amd64.whl (97.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

diptest-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (116.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

diptest-0.4.1-cp39-cp39-macosx_11_0_arm64.whl (86.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

diptest-0.4.1-cp39-cp39-macosx_10_13_x86_64.whl (90.5 kB view details)

Uploaded CPython 3.9 macOS 10.13+ x86-64

diptest-0.4.1-cp38-cp38-win_amd64.whl (97.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

diptest-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (116.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

diptest-0.4.1-cp38-cp38-macosx_11_0_arm64.whl (86.8 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

diptest-0.4.1-cp38-cp38-macosx_10_13_x86_64.whl (90.4 kB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

diptest-0.4.1-cp37-cp37m-win_amd64.whl (97.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

diptest-0.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (117.8 kB view details)

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

diptest-0.4.1-cp37-cp37m-macosx_10_13_x86_64.whl (90.0 kB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: diptest-0.4.1.tar.gz
  • Upload date:
  • Size: 99.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for diptest-0.4.1.tar.gz
Algorithm Hash digest
SHA256 614112238eae74864ff560236cff5a02f304aa77526d5e15a402984d07597edb
MD5 40786ec04813aca91d49569b0f3709b2
BLAKE2b-256 70abc30ffbaf9a246a52a35cbd0b4204a18d59b0c7d52083a650bd39857738d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.4.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 97.5 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

Hashes for diptest-0.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c35c8620e2646c3652a70fe5df0b9cfc5fdccf079f91af0896a01054986b893
MD5 bff4a25ae25ca5f1af07dcec1142bd0e
BLAKE2b-256 2cac7e09f43bf1a0291253dff3672554d94c6a40014da2445f256c7fa2d944a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 831d5de2fea34aa57e57c4a6b358da55eddea38d1625f86790702d8db48cf11a
MD5 cce2339c62e84e61f59c8dfb0fedadb0
BLAKE2b-256 a8da73015f12079440f384035fadeb472054662d2a9a2a0c243195b753f151f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34159caf766972bdab066f1d6f2d9e9c9cd56c718d42727d18edd26e05fca9f7
MD5 ec803cf7bec8d6e5e264376760469e85
BLAKE2b-256 e51c4e6f48a26f1163d07870f37be9d088ded74cefd8a63a192e8522ccc9fddb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 545a024950fa3c3c6fc8ad28a5cb87919ee72dcb7369468593f3ce7cc3f1eecb
MD5 26c5171b5a5b7fb1262700d6ee4e0497
BLAKE2b-256 e8568412892ed15bfc55cf4edc4d64ba2da0cdf3e60d34486aebcdc53c444c69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.4.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 97.1 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

Hashes for diptest-0.4.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8592de1e5f1d3eb7d91a330b7830acd1d978c36fae540fb3d4629aa7e5ab6615
MD5 06cd959b6a5e36b78f041608c049793e
BLAKE2b-256 bf2c269121d7bdae79c40e1c5bb8503dc1a20f76876d62e4d95f41172a2766e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c074832ccd491ac55765f07b355e45e926adbfd14767383bb99ab93c921c4a2e
MD5 ae1d712e64e7d88b2ade2da62919c2da
BLAKE2b-256 192a9f771acfa8de0b19b7c076d473f69ff422829a0c3b5d502814fb55748ee0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2af17861e5136b618673d2a10d5a93107a4d97685c5b77d6e37f1b40a2bf102a
MD5 95cda635ba14f377c193b7fcc4ece74a
BLAKE2b-256 855cc4717207d4a40b7799d69085a9688e2827b66334c6fbb76013a2404bea13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1c620e228c08ed0dadc8ed8afbaff5a23e8ddf7720057ddf7621385074a19345
MD5 6ee3e19130c8f042fae4e6fde152309b
BLAKE2b-256 217f308c6794429b1283c8e240d38df5a677cfb7206d86703c14021cf62a72af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.4.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 97.4 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

Hashes for diptest-0.4.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b0573dcbf7977d59ce264ebf6065aed4a14c96789918a48e03d1aa78d97847c1
MD5 3cfe0f99af69d145e1c84aa154c2cc54
BLAKE2b-256 b9197a273d892c6de3ffb1ea1fcba9ef0af9f02b3a3ebb8b91d3f336553eea31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2ac0f46fda5b63af714d18bc8c310121271068da08d392e0b6c3b43e374e911
MD5 260181068b715eabe3bcfebb701f3596
BLAKE2b-256 35e37bcd6840e1abd9ead97d6162a32ff96d60442811385e89da108adac1b068

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 668916a9bbc6d0886b5b2e44bbc200777a8a16d46fdc3844bb491bb8e4fb6bd2
MD5 2fd51858a4208f1be5628df5abc5825a
BLAKE2b-256 fbe497cf9a754768e8565e8013377356e6aee5c06806071d84fc46438ae49bd3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9c9cecf9e90649798a6399ee68104cbef8624ac372833147d101a194f5c3c622
MD5 cc7c7ec6501a716e444ba471da68f84d
BLAKE2b-256 d719c02f20d0f5b686b3cabc4083ecfc80c32cbab55a6907ecd5c3b1faaca4f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.4.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 97.8 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

Hashes for diptest-0.4.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5415f1ad2342dfcfcf302639d8c01862b08fb4b61d51055c26e03564c1d5ea97
MD5 30d986e849134c70400b3588d6d36646
BLAKE2b-256 5947566d999aa88ac6c80c262c1707c41d7513e38b2e9c5584fb673539889dbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 959a66733c1de59f6d6568cf8ee34fbaafba95ce5486b16fbb0c629ebcd9ba5e
MD5 c705dcf87930b1bb8fedcc0a8217d5cf
BLAKE2b-256 4071e59d61dad0ff70c281a3d57d178452474685dac23efe52c914c6f0f8bac1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.4.1-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e30d1aee29861341bf31a4fc366f78f8fd18e1e9693ee8995433d5c44e2b478c
MD5 c9779848a5d541abe289872ab7a247de
BLAKE2b-256 c5b396ee1f217b3b6af3f51fedb0adf974ad55cd918f5ec5aaa426f850975b73

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