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

Uploaded Source

Built Distributions

diptest-0.6.1-cp311-cp311-win_amd64.whl (100.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

diptest-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (123.9 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

diptest-0.6.1-cp311-cp311-macosx_11_0_arm64.whl (91.6 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

diptest-0.6.1-cp311-cp311-macosx_10_13_x86_64.whl (96.4 kB view details)

Uploaded CPython 3.11 macOS 10.13+ x86-64

diptest-0.6.1-cp310-cp310-win_amd64.whl (99.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

diptest-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

diptest-0.6.1-cp310-cp310-macosx_11_0_arm64.whl (90.4 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

diptest-0.6.1-cp310-cp310-macosx_10_13_x86_64.whl (95.1 kB view details)

Uploaded CPython 3.10 macOS 10.13+ x86-64

diptest-0.6.1-cp39-cp39-win_amd64.whl (99.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

diptest-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

diptest-0.6.1-cp39-cp39-macosx_11_0_arm64.whl (90.4 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

diptest-0.6.1-cp39-cp39-macosx_10_13_x86_64.whl (95.2 kB view details)

Uploaded CPython 3.9 macOS 10.13+ x86-64

diptest-0.6.1-cp38-cp38-win_amd64.whl (99.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

diptest-0.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

diptest-0.6.1-cp38-cp38-macosx_11_0_arm64.whl (90.3 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

diptest-0.6.1-cp38-cp38-macosx_10_13_x86_64.whl (95.1 kB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

diptest-0.6.1-cp37-cp37m-win_amd64.whl (99.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

diptest-0.6.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (122.5 kB view details)

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

diptest-0.6.1-cp37-cp37m-macosx_10_13_x86_64.whl (95.0 kB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: diptest-0.6.1.tar.gz
  • Upload date:
  • Size: 100.1 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.1.tar.gz
Algorithm Hash digest
SHA256 e379a06957736e650bf6bb24431d3a37441cead0576fd1ed2759514a05625aad
MD5 4f7f29198ac82c6e9e6df7ecd50e83a7
BLAKE2b-256 88a7ce68a60a6dadeea3d856d96c828d8fbe85f22c0d4a46487cf15970d2f3f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.6.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 100.3 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 eccf66b8c3051e1da64279a01c19a3e05adb3a1e9fa859aad29c020eab686ca0
MD5 e95814aa91600acbb3b39e2483d781d0
BLAKE2b-256 e501e00cca92b1be05bac2b83bc3832c1160ed35d0b614a19e15801fe6246185

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 274d088515fcfe16ed37343b41268e5b671313e5c5b15962b20077420f4a304e
MD5 df97fab9a821394e06712613d6441bea
BLAKE2b-256 c7098e65917faa19e0c6e8ccf588d10478329837c6828599a26ef24eacf85338

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3dad46bffd19019c5e4d9a75c5f82a30a79e29e28efe4f7357d0393584789712
MD5 c5151f14a703dc578997da121ab45dc1
BLAKE2b-256 45c11ea8310de28eb83863b57a13405eaa85eeb6bf6249c8dad6c3d53a7a02cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7bcbaa12a6a88dccfa6ac4c02707337159245059dc7db6fad0ce24cb07970fa0
MD5 728d81ff737a056926b5fa7900ceae0d
BLAKE2b-256 46668b5f5bf99be1f744b36fa9753056a2bed6a75a59b23c67835b097ee1de29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.6.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 99.4 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 89995e2dd6642fef7f3cd453a248d626791cbc38ec250c00477ff1dbdd1e6b16
MD5 553e35072ca53ed45a4fee93603edfdf
BLAKE2b-256 b77ac2855dbdfdffb8ac9d17716c20a09f5516ef104626d9155a45f43bb3737f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da5d36600b4d4aca4021d18a9beba3faf8d11e17ae96e1272da5cb0a1a46da4d
MD5 4835bf9c3500f642f19a520ac5fee48e
BLAKE2b-256 538e0b3bb9f51edf6cba8df7684e93906f55a420a65099190bc579cc4bdcf861

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 446b992baee2570720569014dd6d0539216e845b7444d3e0331793be92c3343f
MD5 797ca3fc0b62575f8516c7f94a5ab887
BLAKE2b-256 91c79147128d17a0ad12baaefc559de0dad628128576e7d78ecc556da0f4d403

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a048342c185db5a6e227011d3cd8d74074dd22c83656c9c3da21062d959606f2
MD5 5ec8648838191175bf4f49bfaba6e361
BLAKE2b-256 cf34c43d4f7976faa34bec32c7600d89d1439b60874e9fbf07e97a5bb34551fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.6.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 99.3 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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bee765e8a94702b5e909d98d1c3dc0f7838a68ebb51648ce94339ddf2e2189f1
MD5 cdfc6d6c9e63a234b47a36a9a6384457
BLAKE2b-256 c08f36f1a7f1ac260040ca3ae7e43427c900d8f48e2aaf8469b2f6e2e1093c39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae87c9ade59bacb446d8fd07309a12a1a4b991489069dc549342dd142b6f8ece
MD5 b44e6307ad478a470779bc5a3d55419f
BLAKE2b-256 7a5c4846f5c45d26134139d6ff786323c121be8f00fb5524b5040a73dbe98709

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92036a8d7d48d0f78e4fe23a203cf91cb511d9565501b6956518c58bc8e28c77
MD5 864d857982132123c1dcde813349a284
BLAKE2b-256 54521f59677a274ad1a69cad863cc64f14e1809bc1d128ec9c2221c4c8b7acd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 84b4c88592a9d9088b4fa1d2d856aecbe0dba269f15a4e22c7619afabdf9d297
MD5 5f18e8b7267619cc46df306ffc33503e
BLAKE2b-256 592cc31fe4127df86e985ff9b1ef075a8c2f3b98351361e0ed54599adb08562f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.6.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 99.0 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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c6e742621211e6a8e8cc092bdbb518e6180ecd51f95801e6b42afbeab74cf68f
MD5 a55e054b1175354c6d06f3a2758f617c
BLAKE2b-256 2b4a9317524f41f56a9d86df32fb23101592a615cb0896fe2d12d22b4d22cc7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0f10e30c9d5cf715b41509445f46ba72547c513ccb7cec4d58574936686397f
MD5 1d7b394dbc6d14cf68c84d56769146f1
BLAKE2b-256 a1de99810c4d54b8154af979957cb629c5aff654f767720a6afb899017316136

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3942491190d0fc5539735fcc350b83693099c4a8a49c8b8289a059d2eab0551d
MD5 862edafa372c42aac2e6929153105a49
BLAKE2b-256 e2b2a6a103306e1b5b573776a1e1b23f578ca675dd63530670b1cfb512081197

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b22570ef4064185ca5c9b640de69a4a24c8d63ad89db5d8ea98859883e570469
MD5 8e0a90ea442ab3f3116f0e6e5e1b0d66
BLAKE2b-256 f3ba476d2b53622e8e78908bbfe2daa392ca6c445f4a22244e7ac83b4746a3a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diptest-0.6.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 99.9 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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 32a5cb5610d9ba86ca4c5780a76c76ae5abdf4b1393f80b8d453462ea9029b03
MD5 f247c9c4bbfbe85f3218efad4fd48416
BLAKE2b-256 a05d5a6f6b9457a146449fc739584d2c9579a47bd57d240ec881d9bb1e522eb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0a930070067b23125b7f211d9095f60637d4050179097d2983b8d6c96258fb3
MD5 a4697a07eae9d68d52423000cf3fe80a
BLAKE2b-256 a2f02a9fdf0ecf57541e072b9c38c960d3f9d72d3e4cc615e4b39c6fa74e7884

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diptest-0.6.1-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3e7e1ca73c6204e937f97e71732cfc9418f1bfa8e41df76b6e7d0ecb9c2a4210
MD5 314f23a821fb53d1819899a8cf869069
BLAKE2b-256 e4e0a15f4f9d99a023dbea5269c7bd526b77992dee00078eea088161a0d949c8

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