agentleFS
michaelsvanbeekmichaelsvanbeek/personal-agent-skills/skills/statistics/SKILL.md

statistics

Skill1 starsChanged 7 months agoMITView on GitHub

Statistical analysis and hypothesis testing for data-driven decisions. Use when: choosing the right statistical test for a question, calculating sample sizes, running A/B test analysis, comparing distributions, measuring correlation, building confidence intervals, validating assumptions before applying a test, interpreting p-values and effect sizes, or selecting the right summary statistics for a dataset. Covers descriptive statistics, hypothesis testing, regression basics, and practical interpretation.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 15 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 15

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use these to summarize and understand data before testing anything.

    line 72
  2. Distinctive:

    Rule: If mean ≠ median by more than 10–15%, the data is skewed — prefer median.

    line 82
  3. Distinctive:

    If the omnibus test is significant (groups differ), use post-hoc tests to find _which_ groups differ:

    line 139
  4. Distinctive:

    Correlation ≠ causation: Always state this explicitly when reporting.

    line 159
  5. Distinctive:

    Always report effect size alongside significance.

    line 165
  6. Distinctive:

    Before running an experiment, calculate the required sample size:

    line 179
  7. Distinctive:

    When in doubt, aim for more data — underpowered studies waste everyone's time

    line 195
  8. Distinctive:

    Set the duration: Don't peek at results before the required sample size is reached

    line 208
  9. Distinctive:

    Pre-register: Document hypothesis, metric, sample size, and success criteria before launching

    line 209
  10. Distinctive:

    Monitor guardrails: If error rates or latency spike, you have a quality issue, not a test result

    line 215
  11. Distinctive:

    Before applying any parametric test, verify:

    line 246
  12. Distinctive:

    Use the selection guide above.

    line 290
  13. Distinctive:

    Every statistical analysis should produce:

    line 320
  14. Distinctive:

    No multicollinearity (VIF < 5 for each predictor)

    line 346
  15. Distinctive:

    Default stance: Use frequentist methods unless one of the above signals is present.

    line 367

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Core Principles

  1. Question first, method second — Define what you're trying to learn before selecting a test. The question determines the method, not the other way around.
  2. Check assumptions before computing — Every test has assumptions (normality, independence, equal variance). Violating them silently produces misleading results.
  3. Effect size matters more than p-values — A statistically significant result can be practically meaningless. Always report the magnitude of the effect alongside significance.
  4. Confidence intervals over point estimates — A mean of 42 is less useful than "42 ± 5 (95% CI)". Always quantify uncertainty.
  5. Don't test what you can describe — If the question is "what does the data look like?", use descriptive statistics. Hypothesis tests answer "is this difference real?", not "what is the data?"
  6. One question, one test — Running multiple tests on the same data inflates false positives. If you must run multiple comparisons, correct for it (Bonferroni, Holm, or FDR).
  7. Honest reporting — Report all results, not just significant ones. Pre-register your hypothesis when possible. State limitations clearly.

Method Selection Guide

Step 1: Classify Your Question

Question TypeWhat You're AskingGo To
DescribeWhat does the data look like?Descriptive Statistics
CompareAre these groups different?Comparison Tests
RelateDo these variables move together?Correlation & Regression
PredictWhat will happen next?Regression & Modeling (beyond this skill — use ML)
ClassifyDoes this differ from expected?Goodness-of-Fit Tests

Step 2: Identify Your Data Structure

FactorOptionsWhy It Matters
Number of groups1, 2, or 3+Determines which test family to use
Paired or independent?Same subjects measured twice vs. different subjectsPaired tests are more powerful but require matched data
Variable typeContinuous (interval/ratio) vs. categorical (nominal/ordinal)Determines parametric vs. non-parametric
Sample sizeSmall (< 30) vs. large (≥ 30)Small samples need non-parametric or exact tests
Distribution shapeNormal vs. skewed vs. unknownParametric tests assume normality

Descriptive Statistics

Use these to summarize and understand data before testing anything.

Central Tendency

MeasureWhen to UseSensitive To
MeanSymmetric, roughly normal dataOutliers (a single extreme value shifts it)
MedianSkewed data or when outliers are presentNothing — robust by design
ModeCategorical data or multimodal distributionsTies, small samples

Rule: If mean ≠ median by more than 10–15%, the data is skewed — prefer median.

Spread

MeasureWhen to UseNotes
Standard deviationNormal-ish data; pair with meanSame units as data
IQR (Q3 − Q1)Skewed data; pair with medianRobust to outliers
RangeQuick sense of spreadUseless with outliers
Coefficient of variation (CV)Comparing spread across datasets with different scalesCV = std / mean

Distribution Shape

CheckMethodInterpretation
NormalityShapiro-Wilk (n < 5000), Anderson-Darling, or Q-Q plotp < 0.05 → not normal
Skewnessscipy.stats.skew|skew| > 1 = substantially skewed
Kurtosisscipy.stats.kurtosis> 0 = heavy tails, < 0 = light tails

Comparison Tests

Choosing the Right Test

How many groups?
├── 1 group vs. known value
│   ├── Normal → One-sample t-test
│   └── Not normal → Wilcoxon signed-rank
├── 2 groups
│   ├── Paired (same subjects)?
│   │   ├── Normal → Paired t-test
│   │   └── Not normal → Wilcoxon signed-rank
│   └── Independent?
│       ├── Normal, equal variance → Independent t-test
│       ├── Normal, unequal variance → Welch's t-test
│       └── Not normal → Mann-Whitney U
└── 3+ groups
    ├── Normal, equal variance → One-way ANOVA
    ├── Not normal → Kruskal-Wallis
    └── Repeated measures → Repeated measures ANOVA or Friedman test

Test Reference

TestComparesAssumptionsNon-Parametric Alternative
One-sample t-testSample mean vs. known valueNormal, continuousWilcoxon signed-rank
Independent t-testMeans of 2 independent groupsNormal, equal variance, independentMann-Whitney U
Welch's t-testMeans of 2 independent groupsNormal, independent (no equal variance needed)Mann-Whitney U
Paired t-testMeans of 2 paired measurementsNormal differences, continuousWilcoxon signed-rank
One-way ANOVAMeans of 3+ independent groupsNormal, equal variance, independentKruskal-Wallis
Chi-squared testObserved vs. expected frequenciesExpected count ≥ 5 in each cellFisher's exact test

Post-Hoc Tests (After ANOVA / Kruskal-Wallis)

If the omnibus test is significant (groups differ), use post-hoc tests to find which groups differ:

TestWhen to Use
Tukey HSDAll pairwise comparisons, equal sample sizes
Bonferroni correctionFew planned comparisons
Dunn's testPost-hoc for Kruskal-Wallis

Correlation and Association

MethodVariable TypesMeasuresAssumptions
Pearson's rBoth continuousLinear relationship strengthNormal, linear, no outliers
Spearman's ρOrdinal or continuousMonotonic relationship strengthNone (rank-based)
Kendall's τOrdinal, small samplesMonotonic relationship strengthNone (rank-based, more robust than Spearman for small n)
Chi-squared test of independenceBoth categoricalWhether variables are associatedExpected counts ≥ 5
Point-biserialOne binary, one continuousCorrelationNormal continuous variable

Correlation ≠ causation. Always state this explicitly when reporting. A correlation is a starting point for investigation, not a conclusion.


Effect Size

Always report effect size alongside significance. A tiny p-value with a tiny effect is not actionable.

ContextMeasureSmallMediumLarge
2-group comparisonCohen's d0.20.50.8
ANOVAEta-squared (η²)0.010.060.14
Correlationr or R²0.10.30.5
Chi-squaredCramér's V0.10.30.5
Binary outcomeOdds ratio1.52.54.0

Sample Size and Power

Before running an experiment, calculate the required sample size:

## Power Analysis

**Test**: <e.g., "Independent t-test">
**Desired power**: 0.80 (standard) or 0.90 (high confidence)
**Significance level (α)**: 0.05
**Minimum detectable effect (MDE)**: <e.g., "Cohen's d = 0.3" or "5% conversion lift">
**Required sample size per group**: <computed value>
**Expected duration to collect**: <e.g., "2 weeks at current traffic">

Rules of thumb:

  • Power < 0.80 = underpowered; you'll likely miss real effects
  • Larger effects need smaller samples; smaller effects need larger samples
  • When in doubt, aim for more data — underpowered studies waste everyone's time

A/B Testing

A/B tests are the most common applied statistics scenario. Follow this workflow:

Before the Test

  1. State the hypothesis: "Variant B will increase conversion rate by ≥ 5% relative to control"
  2. Choose the metric: Primary metric (what you're optimizing) + guardrail metrics (what must not degrade)
  3. Run power analysis: Calculate required sample size per variant
  4. Set the duration: Don't peek at results before the required sample size is reached
  5. Pre-register: Document hypothesis, metric, sample size, and success criteria before launching

During the Test

  • Don't peek: Checking results daily and stopping early inflates false positives
  • Don't change the test mid-flight: Adding variants, changing allocation, or modifying the feature during the test invalidates results
  • Monitor guardrails: If error rates or latency spike, you have a quality issue, not a test result

After the Test

## A/B Test Results

**Test**: <name>
**Duration**: <start – end>
**Sample size**: Control: <n>, Variant: <n>

**Primary metric**: <metric name>
| Group | Value | 95% CI |
|-------|-------|--------|
| Control | <X> | [<lo>, <hi>] |
| Variant | <X> | [<lo>, <hi>] |

**Relative lift**: <X%> [<CI lo>, <CI hi>]
**p-value**: <X>
**Effect size**: <measure and value>

**Guardrail metrics**: <all stable / degradation in X>

**Decision**: <Ship variant | Keep control | Inconclusive — extend or redesign>
**Reasoning**: <why this decision, referencing effect size and practical significance>

Assumption Validation Checklist

Before applying any parametric test, verify:

AssumptionHow to CheckIf Violated
NormalityShapiro-Wilk test, Q-Q plot, histogramUse non-parametric alternative
Equal varianceLevene's test, F-testUse Welch's t-test or rank-based test
IndependenceStudy design (not a statistical test)Use paired/repeated measures test
Linearity (regression)Scatter plot of residuals vs. fittedTransform variables or use non-linear model
No multicollinearity (regression)VIF < 5 for each predictorRemove or combine correlated predictors

Process

Step 1: State the Question

## Statistical Question

**Question**: <What are you trying to learn? Be specific.>
**Population**: <Who or what does this apply to?>
**Hypothesis** (if testing): 
  - H₀: <null hypothesis — no effect, no difference>
  - H₁: <alternative hypothesis — the effect you expect>
**Practical significance threshold**: <What size effect would actually matter?>

Step 2: Profile the Data

## Data Profile

**Source**: <where the data comes from>
**Sample size**: <n>
**Variables**: 
  - <var1>: <type> — <description>
  - <var2>: <type> — <description>
**Missing data**: <count, percentage, pattern>
**Distribution**: <per variable — normal, skewed, categorical frequencies>
**Assumption checks**: <normality, variance, independence — pass/fail>

Step 3: Select the Method

Use the selection guide above. Document:

## Method Selection

**Test**: <name>
**Why**: <reasoning tied to question type, data structure, and assumption checks>
**Alternative considered**: <what else could work and why it wasn't chosen>
**Correction applied**: <e.g., "Bonferroni for 3 pairwise comparisons" or "none — single test">

Step 4: Compute and Interpret

## Results

**Test statistic**: <name> = <value>
**p-value**: <value>
**Effect size**: <measure> = <value> (<small | medium | large>)
**Confidence interval**: [<lower>, <upper>] at <confidence level>

**Interpretation**: <Plain-language statement of what this means. Not just "p < 0.05 so we reject H₀" — state the practical implication.>

**Limitations**: <What this result does NOT tell us. Confounders, generalizability, assumptions that were borderline.>

Output Format

Every statistical analysis should produce:

  1. Question — What you're trying to learn, with hypothesis if applicable
  2. Data Profile — Summary of the data, assumption checks
  3. Method Selection — Which test, why, and what alternatives were considered
  4. Results — Test statistic, p-value, effect size, confidence interval
  5. Interpretation — Plain-language meaning and practical significance
  6. Limitations — What the result doesn't tell you

Regression Basics

Regression is the most common applied statistics method. Use this decision guide:

Outcome VariablePredictor(s)MethodUse When
Continuous1 continuousSimple linear regressionPredicting one variable from another (e.g., revenue from ad spend)
ContinuousMultipleMultiple linear regressionPredicting with several factors; controlling for confounders
Binary (0/1)AnyLogistic regressionPredicting yes/no outcomes (e.g., churn, conversion)
Count (0, 1, 2...)AnyPoisson regressionPredicting event counts (e.g., support tickets per day)

Before running regression, check:

  • Linearity (scatter plot of residuals vs. fitted)
  • Independence of residuals
  • Homoscedasticity (constant variance of residuals)
  • No multicollinearity (VIF < 5 for each predictor)
  • Normality of residuals (for inference, not prediction)

Key outputs to report: R², adjusted R², coefficients with CIs, residual plots, and F-test p-value.


When to Consider Bayesian Methods

Frequentist methods (everything above) are the default. Consider Bayesian approaches when:

SignalWhy Bayesian Helps
Small sample size (n < 30)Priors regularize unstable estimates
You have strong prior knowledgeIncorporating domain expertise improves estimates
You need P(hypothesis | data), not P(data | hypothesis)Credible intervals answer "what's the probability the effect is > X?" directly
Sequential testing / continuous monitoringBayesian A/B tests allow peeking without inflating error rates
Stakeholders struggle with p-values"95% probability the effect is between 2% and 8%" is more intuitive

Practical tools: pymc, arviz for general Bayesian analysis; Bayesian A/B testing via bayesian-testing or built-in platform features (Optimizely, LaunchDarkly).

Default stance: Use frequentist methods unless one of the above signals is present. Don't switch to Bayesian for complexity's sake.


Tooling Reference

LibraryLanguageBest For
scipy.statsPythonHypothesis tests, distributions, descriptive stats
statsmodelsPythonRegression, ANOVA, time series, assumption diagnostics
pingouinPythonClean API for t-tests, ANOVA, correlation, effect sizes
scikit-learnPythonTrain/test splits, cross-validation, preprocessing
pymcPythonBayesian modeling and inference
power_analysis / statsmodels.stats.powerPythonSample size and power calculations

Common Pitfalls

PitfallWhy It Fails
p-hackingRunning multiple tests and reporting only significant results inflates false positives. Pre-register your hypothesis.
Ignoring effect sizep = 0.001 with Cohen's d = 0.05 means "we're very sure about a trivially small difference." Not actionable.
Small sample, big claimsA study with n = 12 that finds p = 0.04 is fragile. One outlier changes the conclusion.
Violating independenceUsing the same users in both groups, or multiple measurements without paired tests. Results are invalid.
Peeking at A/B testsChecking daily and stopping when p < 0.05 dramatically inflates false positive rate. Use sequential testing if you must peek.
Treating non-significant as "no effect"Absence of evidence ≠ evidence of absence. You may be underpowered. Report power.
Applying parametric tests to ordinal dataA Likert scale (1–5) is not continuous. Use non-parametric methods.
Confusing correlation with causationPearson r = 0.8 does not mean X causes Y. It means they move together.
Cherry-picking subgroups"It wasn't significant overall, but it was significant for users aged 25–30 on Tuesdays." This is noise.
Reporting without uncertainty"Conversion rate is 4.2%" is less useful than "4.2% ± 0.8% (95% CI)." Always show the interval.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.