Registry / analytics / diptest

diptest

JSON →
library0.11.0pypypi✓ verified 85d ago

Python implementation of Hartigan's dip test for unimodality. Current version 0.11.0 (January 2025). Fast O(n log n) implementation. Pre-compiled wheels for major platforms. Releases are stable but infrequent.

pip install diptest
INSTALL
IMPORT
SIG · DIPTEST
D
diptest
analyticspythonv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dipstat
from diptest import dipstat
import diptest.dipstat
dipstat is a function, not a submodule.
dip_pval
from diptest import dip_pval
from diptest.diptest import dip_pval
Direct import from diptest package.

Compute Hartigan's dip statistic and p-value for unimodality on a sample.

import numpy as np from diptest import dipstat, dip_pval np.random.seed(42) data = np.random.normal(0, 1, 200) dip, pval = dipstat(data), dip_pval(dip, len(data)) print(f'Dip statistic: {dip}, p-value: {pval}')
Debug
Known issues
gotchadip_pval expects the dip statistic and sample size, not the raw data. Common mistake: passing data to dip_pval erroneously.
fix
Call dip_pval(dipstat_result, n) where n = len(data).
affects: all
breakingIn version 0.9.0, the function dip_pvals was renamed to dip_pval. Old code using dip_pvals will break.
fix
Update to dip_pval(dip, n) or pin version <0.9.0.
affects: <0.9.0
gotchaThe dip test is sensitive to sample size. For very small samples (n < 20), p-values may be unreliable.
fix
Use with caution for n < 20; consider alternative tests.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'diptest'
Package not installed.
fix
Run 'pip install diptest'.
ValueError: n must be >= 2
Passing a single-element array or empty array to dipstat.
fix
Ensure input data has at least two elements.
Upgrade
Version history
0.11.0latest on PyPI · released Apr 24, 2026
Audit
Dependencies
numpyrequiredData manipulation and array operations
Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
diptest — pip install diptest · libregistry