Read out an A/B test metric with Welch's t-test and return the t-statistic, p-value and decision
Role: Data Scientist
Category: Analytics & Experimentation
Difficulty: easy
Interview Round: Other
Implement `welch_ttest(control: np.ndarray, treatment: np.ndarray, alpha: float = 0.05) -> tuple`. Return `(t_stat, p_value, reject)` where `t_stat, p_value = scipy.stats.ttest_ind(treatment, control, equal_var=False)` and `reject = bool(p_value < alpha)`.
Requirements:
- Use Welch's test (`equal_var=False`), not Student's pooled t-test.
- Pass `treatment` first and `control` second, so a higher treatment mean gives a positive `t_stat`.
- Use the two-sided p-value (scipy's default).
- `reject` uses a strict `<` against `alpha`.
- Return types: `(float, float, bool)`.
Example:
```text
control = [10, 12, 9, 11, 13, 8, 10, 12, 11, 9]
treatment = [12, 14, 11, 13, 15, 10, 13, 14, 12, 11]
alpha = 0.05
Output: (2.82842712474619, 0.01113641309585439, True)
```
The means are 10.5 and 12.5, and each group has sample variance 2.5 over 10 observations, so the standard error is `sqrt(0.5)` and the t-statistic is 2.0 / 0.7071, about 2.8284, with 18 degrees of freedom. The two-sided p-value of about 0.0111 is below 0.05, so the test rejects.
```hint Conventions to pin down
Check which argument SciPy subtracts from which, what it does about variances by default, and what Python types come out of the result object.
```
### What a Strong Answer Covers
- Welch's unequal-variance test and why it is the usual default for A/B metrics.
- The argument order and the sign of `t_stat` that results from it.
- The two-sided p-value and the strict `<` rejection rule.
- Native return types, and what happens on degenerate inputs such as missing values or zero variance.
### Follow-up Questions
- When would you prefer Welch's test over Student's pooled t-test?
- How would you switch to a one-sided test for a directional hypothesis?
- What would you report alongside the p-value in the experiment readout?
Overview: Write a Python function that runs Welch's unequal-variance t-test on treatment and control samples and returns the t-statistic, two-sided p-value and reject decision. It tests SciPy conventions, argument order and sign, a strict significance rule, native return types and when to prefer Welch over the pooled t-test.