{"id":15358955,"url":"https://github.com/rurlus/diptest","last_synced_at":"2025-10-25T01:08:31.997Z","repository":{"id":36961556,"uuid":"457818938","full_name":"RUrlus/diptest","owner":"RUrlus","description":"Python/C++ implementation of Hartigan \u0026 Hartigan's dip test, based on Martin Maechler's R package","archived":false,"fork":false,"pushed_at":"2025-04-28T04:10:47.000Z","size":433,"stargazers_count":21,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"stable","last_synced_at":"2025-05-01T06:39:32.585Z","etag":null,"topics":["data-science","modality","python","statistics","unimodal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"alimuldal/diptest","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RUrlus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-10T14:43:09.000Z","updated_at":"2025-03-31T09:03:45.000Z","dependencies_parsed_at":"2023-01-17T08:47:16.138Z","dependency_job_id":"7efb2ef8-02d2-4633-bead-423ab29866c3","html_url":"https://github.com/RUrlus/diptest","commit_stats":{"total_commits":209,"total_committers":7,"mean_commits":"29.857142857142858","dds":0.2583732057416268,"last_synced_commit":"375e2a99851dd4364ca07295c3f22e8e9355381c"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUrlus%2Fdiptest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUrlus%2Fdiptest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUrlus%2Fdiptest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUrlus%2Fdiptest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RUrlus","download_url":"https://codeload.github.com/RUrlus/diptest/tar.gz/refs/heads/stable","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252903041,"owners_count":21822360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","modality","python","statistics","unimodal"],"created_at":"2024-10-01T12:43:26.039Z","updated_at":"2025-10-25T01:08:31.883Z","avatar_url":"https://github.com/RUrlus.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diptest\n\n[![Linux Build](https://github.com/RUrlus/diptest/actions/workflows/linux.yml/badge.svg)](https://github.com/RUrlus/diptest/actions/workflows/linux.yml)\n[![Windows Build](https://github.com/RUrlus/diptest/actions/workflows/windows.yml/badge.svg)](https://github.com/RUrlus/diptest/actions/workflows/windows.yml)\n[![MacOS build](https://github.com/RUrlus/diptest/actions/workflows/macos.yml/badge.svg)](https://github.com/RUrlus/diptest/actions/workflows/macos.yml)\n[![PyPi](http://img.shields.io/pypi/v/diptest.svg)](https://pypi.org/project/diptest/)\n\nA Python/C(++) implementation of Hartigan \u0026 Hartigan's dip test for unimodality.\n\nThe dip test measures multimodality in a sample by the maximum difference, over\nall sample points, between the empirical distribution function, and the\nunimodal distribution function that minimizes that maximum difference. Other\nthan unimodality, it makes no further assumptions about the form of the null\ndistribution.\n\n## Usage\n\nThis library provides two functions:\n* `dipstat`\n* `diptest`\n\nThe first only computes Hartigan's dip statistic. `diptest` computes both the\nstatistic and the p-value. The p-value can be computed using interpolation of a\ncritical value table (default) or by bootstrapping the null hypothesis.\nNote that for larger samples (N \u003e 1e5) this is quite compute and memory intensive.\n\n```python3\n    import numpy as np\n    import diptest\n\n    # generate some bimodal random draws\n    N = 1000\n    hN = N // 2\n    x = np.empty(N, dtype=np.float64)\n    x[:hN] = np.random.normal(0.4, 1.0, hN)\n    x[hN:] = np.random.normal(-0.4, 1.0, hN)\n\n    # only the dip statistic\n    dip = diptest.dipstat(x)\n    \n    # both the dip statistic and p-value\n    dip, pval = diptest.diptest(x)\n```\n\n## Dependencies\n* `numpy`\n* [Optional] `OpenMP`\n\nParallelisation of the p-value computation using bootstrapping is offered using OpenMP.\nOpenMP is disabled by default but can be enabled, see installation section\nbelow.\n Multi-threading can be turned off by setting the number of threads equal to 1. See the docstring of `diptest` for details.\n\n\n## Installation\n\ndiptest can be installed from PyPi using:\n\n```bash\n    pip install diptest\n```\n\nWheels containing the pre-compiled extension are available for:\n\n- Windows x84-64 - CPython 3.8 - 3.12\n- Linux x84-64 - CPython 3.8 - 3.12\n- MacOS x84-64 - CPython 3.8 - 3.12\n- MacOS ARM-64 - CPython 3.8 - 3.12\n\nNote that the wheels vendor/ships OpenMP with the extension to provide parallelisation out-of-the-box.\nIf you run into issue with multiple versions of OpenMP being loaded you have two options: build from source or install a non-bundled wheel.\n\n### Non-bundled wheels\n\nWe provide the same wheels without OpenMP bundled here: https://github.com/RUrlus/diptest/releases \nYou than install the wheel that corresponds to your Python and OS.\nFor example, for CPython 3.11 and MacOS ARM:\n\n```shell\npip install diptest-0.8.0-cp311-cp311-macosx_11_0_arm64.whl\n```\n\n### Building from source\n\nIf you have a C/C++ compiler available it is advised to install without\nthe wheel as this enables architecture specific optimisations.\n\n```bash\n    pip install diptest --no-binary diptest\n```\n\nCompatible compilers through Pybind11:\n\n- Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or newer)\n- GCC 4.8 or newer\n- Microsoft Visual Studio 2015 Update 3 or newer\n- Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)\n- Cygwin/GCC (previously tested on 2.5.1)\n- NVCC (CUDA 11.0 tested in CI)\n- NVIDIA PGI (20.9 tested in CI)\n\n#### 64bit index\n\nIn case you work with very large sample sizes you can use 64bit indexes.\n\n```bash\n    CMAKE_ARGS=\"-DDIPTEST_64BIT_index=ON\" pip install diptest --no-binary diptest\n```\n\n#### Disable OpenMP\n\nTo disable OpenMP use:\n\n```bash\n    CMAKE_ARGS=\"-DDIPTEST_DISABLE_OPENMP=ON\" pip install diptest --no-binary diptest\n```\n\n#### Debug installation\n\nTo enable a debug build use:\n```bash\n    CMAKE_ARGS=\"-DCMAKE_BUILD_TYPE=Debug\" pip install diptest --no-binary diptest\n```\n\n#### Debug printing\n\nTo enable the debug print statements use:\n```bash\n    CMAKE_ARGS=\"-DDIPTEST_ENABLE_DEBUG=ON\" pip install diptest --no-binary diptest\n```\nthen call the function with debug argument set to a value greater than zero:\n```python3\n    diptest(x, debug=1)\n```\n\n## References\n\nHartigan, J. A., \u0026 Hartigan, P. M. (1985). The Dip Test of Unimodality. The\nAnnals of Statistics.\n\nHartigan, P. M. (1985). Computation of the Dip Statistic to Test for\nUnimodality. Journal of the Royal Statistical Society. Series C (Applied\nStatistics), 34(3), 320-325.\n\n## Acknowledgement\n\n`diptest` is just a Python port of [Martin Maechler's R module of the same\nname](http://cran.r-project.org/web/packages/diptest/index.html).\nThe package wrapping the C implementation was originally written by [Alistair Muldal](https://github.com/alimuldal/diptest).\nThe fork is an update with a number of changes:\n* Fixes a buffer overrun issue in `_dip.c` by reverting to the original C implementation\n* Python bindings using Pybind11 (C++) instead of Cython\n* P-value computation using bootstrapping has been moved down to C++ with optional parallelisation support through OpenMP\n* Removed overhead caused by debug branching statements by placing them under a compile-time definition\n* Added tests and wheel support\n* C implementation of diptest was rewritten in C++ by [Prodromos Kolyvakis](https://github.com/prokolyvakis)\n\n## License\n\n`diptest` is free software: you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the Free Software\nFoundation, either version 3 of the License, or (at your option) any later\nversion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frurlus%2Fdiptest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frurlus%2Fdiptest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frurlus%2Fdiptest/lists"}