statistical-analysis-and-experiments
БесплатноБез исполняемых скриптовНе проверенUse when designing or analysing an A/B test, computing power or sample size, testing whether a difference is real, or writing any statistical claim — effect…
от makifbaysal★ 123 звезды на GitHubОб этом скилле
Statistical Analysis and Experiments
Overview
A statistical claim is a decision under uncertainty. The analysis has to say how big the effect is, how sure we are, and what could make it wrong — not just whether p < 0.05. The statistics code is production code too: it gets tests.
Core principle: decide the design (metric, unit, sample size, stopping rule) before looking at results; report effect size with a confidence interval; treat every causal-sounding sentence as a claim that needs a design behind it.
1. Describe before you test
- Report mean and median for business metrics; a large gap means skew and the mean alone misleads.
- Use percentiles (p5, p25, p50, p75, p95, p99) and the IQR for skewed data, standard deviation for roughly symmetric data.
- State shape, bounds (a floor at zero, a ceiling at 100%) and how outliers were handled. Never drop outliers silently: classify them as data errors (fix or exclude, with a count), genuine extremes (keep, use robust statistics) or a different population (segment).
2. Design an experiment before it runs
Write these down, in the task or your closing message, before analysing anything:
| Item | Example |
|---|---|
| Hypothesis | New checkout raises conversion |
| Primary metric (one) | Orders / visitors, per user |
| Guardrails | Refund rate, page latency |
| Randomisation unit = analysis unit | User (not session, not page view) |
| Minimum detectable effect | +1.0 percentage point on a 10% baseline |
| α, power | 0.05 two-sided, 0.80 |
| Sample size and duration | Computed below; whole weeks to cover weekly cycles |
| Stopping rule | Analyse once at the planned sample size |
from statsmodels.stats.power import NormalIndPower
from statsmodels.stats.proportion import proportion_effectsize
effect = proportion_effectsize(0.11, 0.10)
n_per_arm = NormalIndPower().solve_power(effect_size=effect, alpha=0.05, power=0.8, ratio=1.0)
If the traffic cannot reach n_per_arm in a reasonable time, say so before the test runs — an underpowered test produces noise and exaggerated "wins".
3. Analyse in this order
- Sample ratio mismatch first. Observed assignment counts against the planned split:
scipy.stats.chisquare([n_a, n_b], f_exp=[expected_a, expected_b]). A very small p-value (below 0.001) means assignment or logging is broken — stop and report that instead of an effect. - The primary metric, once.
- Proportions:
proportions_ztest(count=[x_b, x_a], nobs=[n_b, n_a])and the interval for the difference withconfint_proportions_2indep(x_b, n_b, x_a, n_a). - Means: Welch's t-test,
scipy.stats.ttest_ind(b, a, equal_var=False). - Heavy-tailed metrics (revenue): a bootstrap interval for the difference of means, resampling whole users.
- Ratio metrics where the analysis unit differs from the randomisation unit (revenue per session, randomised by user): delta method or a user-level bootstrap — never a row-level t-test.
- Proportions:
- Effect size with its interval, absolute and relative, compared with the MDE. "Significant" but far below the MDE is weak practical evidence; "not significant" with a wide interval is "inconclusive", not "no effect".
- Guardrails, then exploratory segments — labelled as exploratory.
4. Multiple comparisons and peeking
- Ten metrics or ten segments at α = 0.05 will produce "findings" by chance. Correct the family:
statsmodels.stats.multitest.multipletests(p_values, alpha=0.05, method="holm")(or"fdr_bh"for many exploratory comparisons), and report how many tests were run. - Checking the p-value daily and stopping when it dips under 0.05 inflates the false-positive rate far above α. Analyse at the planned sample size; if early stopping is a requirement, it needs a sequential design chosen in advance.
5. Causal caveats — say them when they apply
- Correlation is not causation: confounding, reverse causation, coincidence. Without randomisation, write "users who use X retain better", not "X improves retention".
- Simpson's paradox: an aggregate trend can reverse inside every segment because the mix shifted. Check the key segments before concluding.
- Survivorship bias: analysing only entities still present (current customers, surviving stores).
- Selection bias: segments defined by the outcome or by self-selection ("users who finished onboarding retain better").
- Ecological fallacy: group-level relations applied to individuals.
- Regression to the mean: units picked for being extreme drift back without any intervention.
- Novelty and primacy effects: early experiment days differ from the steady state.
6. Test the statistics code
Hand-computed cases pin the arithmetic; simulation pins the behaviour.
def test_ab_test_false_positive_rate_is_near_alpha() -> None:
rng = np.random.default_rng(0)
p_values = np.array([
two_proportion_test(rng.binomial(1, 0.10, 2_000), rng.binomial(1, 0.10, 2_000)).p_value
for
Установить statistical-analysis-and-experiments в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл statistical-analysis-and-experiments?
Use when designing or analysing an A/B test, computing power or sample size, testing whether a difference is real, or writing any statistical claim — effect sizes with intervals, SRM checks, multiple comparisons and causal caveats
Как установить скилл statistical-analysis-and-experiments?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл statistical-analysis-and-experiments запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic