spectral_connectivity.statistics.Benjamini_Hochberg_procedure#
- Benjamini_Hochberg_procedure(p_values: ndarray[tuple[int, ...], dtype[floating]], alpha: float = 0.05) ndarray[tuple[int, ...], dtype[bool]][source]#
Control false discovery rate using Benjamini-Hochberg procedure.
Corrects for multiple comparisons and returns significant p-values by controlling the false discovery rate at level alpha using the Benjamini-Hochberg procedure.
- Parameters:
p_values (NDArray[floating], shape (...,)) – P-values from statistical tests to be corrected.
alpha (float, default=0.05) – Expected proportion of false positive tests (false discovery rate).
- Returns:
is_significant – Boolean array same shape as p_values indicating whether the null hypothesis has been rejected (True) or failed to reject (False).
- Return type:
NDArray[bool], shape (…,)
Examples
>>> import numpy as np >>> p_vals = np.array([0.001, 0.02, 0.04, 0.3, 0.8]) >>> significant = Benjamini_Hochberg_procedure(p_vals, alpha=0.05) >>> significant array([ True, True, False, False, False])
Notes
Non-finite p-values (
NaN/inf) mark undefined tests — for example a coherence pair involving a dead/zero-power channel — and are excluded from the family: they neither count toward the number of tests nor tighten the threshold for the valid ones, and are returned asFalse. If every p-value is non-finite (the whole family is undefined, e.g. every tested pair involves a dead channel) aUserWarningis emitted, because the all-False result would otherwise be indistinguishable from a valid family with no true effects. All input dimensions are pooled into a single family (the array is raveled); the result has the input shape. Delegates toscipy.stats.false_discovery_control()(SciPy >= 1.11; a clearRuntimeErroris raised on older SciPy), which rejects finite p-values outside[0, 1].