All problems
Benjamini-Hochberg Step (Small)
Problem
Return the number of rejections from the Benjamini-Hochberg procedure: sort the p-values and find the largest k with p_(k) <= (k/m)*alpha, returning 0 when no p-value qualifies. Return 0 for an empty list.
Hint
Scan from the smallest p-value and keep the last position that passes its line.
Test cases
case 1
in: [[0.01,0.02,0.03,0.04],0.05]
expected: 4
case 2
in: [[0.5,0.6],0.05]
expected: 0
case 3
in: [[0.001,0.5],0.05]
expected: 1
case 4
in: [[],0.05]
expected: 0
case 5
in: [[0.01,0.04,0.03],0.05]
expected: 3
Starter codePython
def benjamini_hochberg(pvals, alpha):
# Your code here
pass5 test cases · run your code against them in the editor