diptest
Hartigan's diptest.
What it is and what it does
diptest is a Python/C++ implementation of Hartigan & Hartigan's statistical test for unimodality. It computes a dip statistic that measures the maximum vertical distance between an empirical cumulative distribution function and the best-fitting unimodal distribution, making no assumptions about the null distribution's form beyond unimodality.
The package exposes two main functions: `dipstat` computes only the dip statistic, while `diptest` returns both the statistic and a p-value. P-values can be computed via interpolation of a critical value table (default, fast) or by bootstrapping the null hypothesis (slower but more accurate for non-standard cases). Bootstrapping supports optional OpenMP-based parallelization for speed.
Use it for:
- Test whether a univariate sample is unimodal or contains multiple modes, useful in exploratory data analysis.
- Detect bimodality or multimodality in biological measurements, particle size distributions, or other empirical samples.
- Validate assumptions in statistical modeling pipelines that require unimodal data.
- Compare modality across groups or conditions by computing dip statistics for each sample.
- Perform hypothesis testing on the null hypothesis of unimodality without assuming a specific parametric form.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Computes Hartigan's dip test statistic and p-value to detect multimodality in a sample, measuring how far an empirical distribution deviates from unimodality.
Yes, if you need to test for unimodality in univariate samples. The package is actively maintained, has no known vulnerabilities, installs easily on modern Python versions via pre-built wheels, and implements a well-established statistical test. Copyleft licensing is a consideration only if you plan to redistribute modified code; using it as a library in a proprietary application is permissible. Medium install friction is negligible for most users thanks to wheel availability.
Install
diptest on PyPI
pip
pip install diptestuv
uv add diptestpoetry
poetry add diptestInstalling diptest
Before you install
Medium install friction due to compiled C++ extension with optional OpenMP parallelization. Pre-built wheels are available for Python 3.8–3.14 on Windows, Linux, and macOS (both x86_64 and ARM64), so most users will install without compilation. Building from source requires a compatible C/C++ compiler.
License in practice
Licensed under GPLv2+, a copyleft license. Any derivative work or modification must be distributed under the same or compatible GPL terms; proprietary or closed-source projects incorporating this code must comply with GPL obligations.
Quickstart
import numpy as np
import diptest
x = np.random.normal(0, 1, 1000)
dip, pval = diptest.diptest(x)
Requires numpy and psutil as runtime dependencies; Python >= 3.8.
Verify before relying
- Whether the package's performance characteristics (compute and memory intensity for N > 1e5) are acceptable for your typical sample sizes.
- Whether OpenMP bundling in pre-built wheels causes conflicts with other OpenMP-linked libraries in your environment.
Package facts
| License | GPLv2+ (copyleft) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — psutil, numpy |
| Maintenance | actively maintained — 112 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 192,953/month — #9,855 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: diptest-0.11.0-cp310-cp310-macosx_13_0_arm64.whl; diptest-0.11.0-cp310-cp310-macosx_13_0_x86_64.whl; diptest-0.11.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; diptest-0.11.0-cp310-cp310-win_amd64.whl; diptest-0.11.0-cp311-cp311-macosx_13_0_arm64.whl; diptest-0.11.0-cp311-cp311-macosx_13_0_x86_64.whl; diptest-0.11.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; diptest-0.11.0-cp311-cp311-win_amd64.whl; diptest-0.11.0-cp312-cp312-macosx_13_0_arm64.whl; diptest-0.11.0-cp312-cp312-macosx_13_0_x86_64.whl; diptest-0.11.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; diptest-0.11.0-cp312-cp312-win_amd64.whl; diptest-0.11.0-cp313-cp313-macosx_13_0_arm64.whl; diptest-0.11.0-cp313-cp313-macosx_13_0_x86_64.whl; diptest-0.11.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; diptest-0.11.0-cp313-cp313-win_amd64.whl; diptest-0.11.0-cp314-cp314-macosx_13_0_arm64.whl; diptest-0.11.0-cp314-cp314-macosx_13_0_x86_64.whl; diptest-0.11.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; diptest-0.11.0-cp314-cp314-win_amd64.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
powershapPowershap performs feature selection by testing…
permissive · top 15,000 on PyPI
hyppohyppo provides multivariate hypothesis testing…
permissive · top 15,000 on PyPI
bootstrappedBuilds confidence intervals from data samples…
unclear · top 15,000 on PyPI
pingouinPingouin provides a comprehensive statistical…
copyleft · top 15,000 on PyPI
scikit-posthocsProvides post hoc statistical tests for…
permissive · top 15,000 on PyPI
krippendorffComputes Krippendorff's alpha, a statistical…
copyleft · top 15,000 on PyPI
lightgbmLightGBM is a gradient boosting framework for…
unclear · top 1,000 on PyPI
moocoreProvides fast implementations of core…
copyleft · top 5,000 on PyPI
empirical-calibrationComputes empirical calibration weights to…
permissive · top 15,000 on PyPI
dipyDIPY is a Python library for analyzing…
permissive · top 15,000 on PyPI