critband: A Python Package for Critical Bandwidth Analysis of Multimodal Distributions

2026-05-18Mathematical Software

Mathematical Software
AI summary

AI summary is being generated…

Authors
Ruiyu Zhang, Qihao Wang
Abstract
Multimodal density estimation is a fundamental problem in scientific computing, but Python has lacked a cohesive implementation of critical bandwidth analysis and related mode-counting tools. We present critband, a Python package for Silverman-style critical bandwidth detection and multimodality assessment based on Gaussian kernel density estimation. The package provides a hybrid binary-Brent critical bandwidth solver, FFT-accelerated KDE for large samples, bootstrap confidence intervals with explicit failure accounting, support for arbitrary mode-count thresholds, component decomposition, bimodality strength scoring, and excess-mass estimation. We validate the implementation on twelve benchmark mixtures spanning well-separated, borderline, unequal-variance, unequal-weight, trimodal, and small-sample cases, and cross-check results against the R multimode package. Across the tested cases, critband reproduces critical bandwidth behavior closely and provides substantially faster runtime for the core search routine. The package is distributed on PyPI and is designed to integrate cleanly into the Python scientific computing stack.