skillfed

diptest

Hartigan's diptest.

diptest v0.11.0 193.0K downloads/30d#9,855 on PyPI33
Copyleft license GPLv2+ Active released

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 diptest

uv

uv add diptest

poetry

poetry add diptest

Installing 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

dip test unimodalitymultimodality detectionhartigan dip statisticstatistical distribution testingbimodality hypothesis testempirical distribution analysissample modality assessment
statistical-testingdistribution-analysis

More Mathematics packages