Skip to content

Goff in wins vs losses — t-test

Level 3 · Challenge 8
All-Pro

Prompt

Run an independent t-test (Welch’s) on Jared Goff’s 2022-2024 regular- season passing yards, comparing Lions wins to Lions losses. (The single 2024 season has only 2 losses — the test would be effectively undefined. Pool the three seasons to get a sample with actual power.) Print the mean for each group, the sample sizes, the t-statistic, and the p-value. Then write 1-2 sentences interpreting the result honestly.

Expected output

Sample output shape (real numbers will vary slightly with your data snapshot):

Wins: n=36, mean=265.x
Losses: n=15, mean=232.x
t ≈ 1.x, p ≈ 0.1x

Plus a short interpretation.

Hint

Pull Goff’s per-week passing yards and the Lions result for each 2022-2024 regular-season week (CTE or two-query merge). Split into two arrays. stats.ttest_ind(wins, losses, equal_var=False). For comparison, also report the 2024-only split — it’ll be n=15 wins / n=2 losses, and you’ll see why we pool.

Solution
import pandas as pd
from scipy import stats
from sqlalchemy import create_engine
eng = create_engine("postgresql+psycopg://onepride:lions@localhost:5432/onepride")
df = pd.read_sql(
"""
WITH games AS (
SELECT season, week,
CASE
WHEN home_team = 'DET' AND home_score > away_score THEN 'W'
WHEN away_team = 'DET' AND away_score > home_score THEN 'W'
WHEN home_score = away_score THEN 'T'
ELSE 'L'
END AS result
FROM schedules
WHERE season BETWEEN 2022 AND 2024
AND game_type = 'REG'
AND (home_team = 'DET' OR away_team = 'DET')
)
SELECT g.season, g.week, g.result, ws.passing_yards
FROM games g
JOIN weekly_stats ws USING (season, week)
WHERE ws.player_display_name = 'Jared Goff'
AND ws.season_type = 'REG'
""",
eng,
)
wins = df.loc[df['result'] == 'W', 'passing_yards']
losses = df.loc[df['result'] == 'L', 'passing_yards']
t, p = stats.ttest_ind(wins, losses, equal_var=False)
print(f"Wins: n={len(wins)}, mean={wins.mean():.1f}")
print(f"Losses: n={len(losses)}, mean={losses.mean():.1f}")
print(f"t = {t:.2f}, p = {p:.3f}")

Interpretation: 36 wins vs 15 losses gives a real sample. You’ll usually see a positive gap (Goff’s averages are higher in wins than in losses) but the p-value is often above the 0.05 convention. The honest read is “there’s a measurable but not statistically certain edge — and most of that gap is probably caused by the game state, not Goff himself.”

Now try filtering to season = 2024 only. You’ll get n=15 wins / n=2 losses — Welch’s t-test on n=2 has one degree of freedom; the result is mathematically defined but practically meaningless. That’s the real-world reminder: situational splits inside a single 17-game season are usually too small to test.