PythiloLesson 10 of 12 · progress kept in this browser

Practice in Lab: Adjust a family of discoveries without losing original order →

Adjust a family of discoveries without losing original order

Trying many hypotheses and reporting only the smallest unadjusted p-value creates false discoveries. Benjamini-Hochberg adjustment controls the expected false-discovery proportion under its assumptions by considering the whole declared family.

Sort p-values, multiply by family size divided by rank, and apply a reverse cumulative minimum. Without that last step adjusted values can violate rank monotonicity. Return results in the original hypothesis order so decisions remain attached to the correct experiment. Selecting the family after inspecting results defeats the point of the adjustment.

pvalues=[.01,.04,.03]
ranked=sorted(enumerate(pvalues),key=lambda x:x[1])
print(ranked)
Your task

Implement bh_adjust(pvalues) returning BH adjusted values in original order, capped at 1. Accept empty input. Reject nonfinite values or values outside [0,1].