Apply the Benjamini-Hochberg FDR correction to a list of p-values
Role: Data Scientist
Category: Analytics & Experimentation
Difficulty: medium
Interview Round: Other
Implement `bh_corrected_pvalues(pvals, alpha=0.05)` to apply the Benjamini-Hochberg (`fdr_bh`) procedure and return only the corrected p-values. Use `statsmodels.stats.multitest.multipletests(pvals, alpha=alpha, method='fdr_bh')`, which returns `(reject, pvals_corrected, alphacSidak, alphacBonf)`.
```python
def bh_corrected_pvalues(pvals: list[float], alpha: float = 0.05) -> np.ndarray:
...
```
Requirements:
- Return a 1-D `float64` numpy array of length `m` (one value per input p-value).
- Preserve the original input order: do not re-sort.
- Return only `pvals_corrected` (index 1), not the `reject` array.
Example:
```python
bh_corrected_pvalues([0.001, 0.008, 0.039, 0.041, 0.042, 0.06, 0.074, 0.205, 0.212, 0.216])
# -> array([0.01, 0.04, 0.084, 0.084, 0.084, 0.1, 0.10571429, 0.216, 0.216, 0.216])
```
```hint Reading the tuple
Check what each element of the returned tuple holds and whether the corrected values come back in sorted order or in input order.
```
```hint Checking the example by hand
Work out the BH threshold that goes with each rank, and notice that the adjusted values never decrease as the rank increases. Ask what step enforces that.
```
### What a Strong Answer Covers
- Which element of the `multipletests` result to return, with its type, length and order
- How the BH step-up adjustment is computed, including the monotonicity step and the cap at 1
- A hand check of at least part of the example
- How the corrected p-values relate to the reject decision at a given `alpha`
- What BH controls (the false discovery rate) compared with a family-wise correction such as Bonferroni
### Follow-up Questions
- How does the `reject` array relate to the corrected p-values?
- When would you prefer `fdr_by` over `fdr_bh`?
- Why does changing `alpha` leave the returned values unchanged?
- How many of the ten example tests would Bonferroni reject at 0.05, and when is that stricter answer the right one?
Overview: Write a function that applies the Benjamini-Hochberg procedure to a list of p-values and returns the corrected values in their original order. It tests how the step-up adjustment works, how corrected p-values map to reject decisions, and how false discovery rate control differs from family-wise corrections.