autoemx.utils.unimodality module
Hartigan’s dip test of unimodality.
- Implemented from the method described in:
J. A. Hartigan and P. M. Hartigan, “The Dip Test of Unimodality”, The Annals of Statistics 13(1), 70-84 (1985).
The dip of a sample is the largest distance between its empirical distribution function and the closest unimodal distribution function. It is computed by shrinking a candidate modal interval: on its left the unimodal fit is the greatest convex minorant (GCM) of the empirical distribution, on its right the least concave majorant (LCM). The p-value is the fraction of uniform samples of the same size (the least favourable unimodal distribution) with a larger dip.
- autoemx.utils.unimodality.dip_statistic(values) float[source]
Hartigan’s dip statistic of a 1D sample (between 1/(2n) and 1/4; larger means less unimodal).
Tied values are handled as a single point with the combined weight of its copies.
- autoemx.utils.unimodality.dip_test(values, n_sims: int = 2000, seed: int = 0) Tuple[float, float][source]
Hartigan’s dip test of unimodality.
Returns the dip statistic and the p-value: the fraction of uniform samples of the same size whose dip is at least as large. Small p-values (e.g. < 0.05) indicate more than one mode.