Multimodal density estimation is a fundamental problem in scientific computing. Determining the number of modes in a distribution is a core numerical challenge with applications across ecology, economics, genomics, and astronomy. While the R ecosystem provides mature tools through the multimode package, the Python ecosystem has lacked an equivalent cohesive implementation. We present critband, a Python package for critical bandwidth bimodality detection based on Silverman's kernel density approach. The package implements critical bandwidth search with a robust bracketed mode-count solver and FFT-accelerated KDE, and provides additional features including k-mode detection, component decomposition, bimodality strength quantification, and excess mass estimation. Validation against twelve benchmark cases spanning separation regimes, unequal variances, unequal weights, and small sample sizes shows stable estimates for clearly separated cases and expected instability for boundary cases. Performance benchmarks show critband is typically 3-10 times faster per case than R's modetest() in the tested setup.
翻译:多模态密度估计是科学计算中的基本问题。确定分布中的模态数量是核心数值挑战,在生态学、经济学、基因组学和天文学中具有广泛应用。尽管R生态系统通过multimode包提供了成熟工具,但Python生态系统一直缺乏等效的连贯实现。我们提出了critband,一个基于Silverman核密度方法进行临界带宽双峰检测的Python包。该包实现了带有鲁棒括号化模态计数求解器和FFT加速核密度估计的临界带宽搜索,并提供额外功能,包括k模态检测、分量分解、双峰强度量化和过剩质量估计。对十二个跨越分离程度、不等方差、不等权重和小样本量的基准案例的验证表明,对于清晰分离的案例,估计结果稳定,对于边界案例,结果呈现预期的不稳定性。性能基准测试表明,在测试设置中,critband每个案例的速度通常比R的modetest()快3到10倍。