Agent skill

Statistics Fundamentals

by JoelLewis in JoelLewis/finance_skills

Apply statistical methods to financial data including descriptive statistics, covariance estimation, regression, hypothesis testing, and resampling.

MITAuto-check passedData & Analytics

Install Statistics Fundamentals

skills CLI
$ npx skills add JoelLewis/finance_skills --skill statistics-fundamentals -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install JoelLewis/finance_skills statistics-fundamentals --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/JoelLewis/finance_skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/core/skills/statistics-fundamentals .claude/skills/statistics-fundamentals && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
statistics-fundamentals
GitHub stars
206
Token cost
~2.2k tokens
SKILL.md length
952 words
Files
2 (incl. scripts)
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Apply statistical methods to financial data including descriptive statistics, covariance estimation, regression, hypothesis testing, and resampling.

  • Works in 3 steps: From the original n observations, draw B… → Compute the statistic on each resample. → Percentile method: the (1 - alpha)…
  • The user asks about return distributions
  • SKILL.md covers Core Concepts, Worked Examples, Common Pitfalls and Running the Script, plus 1 more section
  • Runs Python scripts from its folder; calls uv and python3

What it does

Statistics Fundamentals is an agent skill from JoelLewis/finance_skills. Apply statistical methods to financial data including descriptive statistics, covariance estimation, regression, hypothesis testing, and resampling. Use when the user asks about return distributions, correlation between assets, building a covariance matrix, running a CAPM regression, testing whether alpha is significant, checking if returns are normal, or estimating confidence intervals. Also trigger when users mention 'volatility', 'how correlated are these', 'fat tails', 'skewness', 'R-squared', 'beta of a…

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including scripts (for example `scripts/statistics_fundamentals.py`).

It sits in Data & Analytics, covering Statistics. The repository describes itself as: Claude Code skill plugins for financial services — 81 skills across 7 domain plugins covering investment management, compliance, advisory practice, trading, and operations. The licence is MIT.

When your agent uses it

  • The user asks about return distributions
  • Correlation between assets
  • Building a covariance matrix
  • Running a CAPM regression

Example prompts

  • “volatility”
  • “how correlated are these”
  • “fat tails”
  • “/statistics-fundamentals”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. From the original n observations, draw B resamples of size n with replacement (B = 1,000-10,000).
  2. Compute the statistic on each resample.
  3. Percentile method: the (1 - alpha) confidence interval is the alpha/2 and 1 - alpha/2 percentiles of the bootstrap distribution; the…

What it can do on your machine

Read from SKILL.md and the folder at commit 5c498ea. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • uv
    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Statistics Fundamentals loads about 2.2k tokens when it runs. Until then it costs about 166 tokens; SKILL.md has 952 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~166
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from JoelLewis/finance_skills at commit 5c498ea, republished under its MIT licence (© JoelLewis). 952 words, ~2,244 tokens.

Download SKILL.mdSave it as .claude/skills/statistics-fundamentals/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
statistics-fundamentals
description
Apply statistical methods to financial data including descriptive statistics, covariance estimation, regression, hypothesis testing, and resampling. Use when the user asks about return distributions, correlation between assets, building a covariance matrix, running a CAPM regression, testing whether alpha is significant, checking if returns are normal, or estimating confidence intervals. Also trigger when users mention 'volatility', 'how correlated are these', 'fat tails', 'skewness', 'R-squared', 'beta of a fund', 'bootstrap a Sharpe ratio', 'shrinkage estimator', 'Ledoit-Wolf', or ask why their optimizer produces unstable weights.

Statistics Fundamentals

Core Concepts

Conventions and Decision Rules
Sample variance: use n-1

When estimating variance or standard deviation from a sample of returns, divide by n - 1 (Bessel's correction), not n. Dividing by n systematically underestimates dispersion. Standard deviation of returns is "volatility"; annualize with sigma_annual = sigma_period * sqrt(periods_per_year) (e.g., * sqrt(12) for monthly, * sqrt(252) for daily).

Normality testing: Jarque-Bera and its limits

JB = (n/6) * (skew^2 + excess_kurtosis^2 / 4), distributed chi-squared with 2 df under the null of normality (5% critical value: 5.99).

Low-power caveat: with small samples (n below roughly 50), JB rarely rejects even for clearly non-normal data — failing to reject is weak evidence of normality, not confirmation. With large samples, financial return series almost always reject due to fat tails and (for equities) negative skewness. Treat the test as a screen, and pair it with a look at the actual skew/kurtosis magnitudes and extreme observations.

Covariance estimation and Ledoit-Wolf shrinkage

The sample covariance matrix Sigma_hat = (1/(n-1)) (X - X_bar)^T (X - X_bar) becomes poorly conditioned or singular when the number of assets p approaches the number of observations n. Plugging it into a mean-variance optimizer then produces extreme, unstable weights that flip with small data changes.

Shrinkage blends the sample matrix toward a structured target:

$$\hat{\Sigma}_{shrunk} = \delta \cdot F + (1 - \delta) \cdot \hat{\Sigma}$$

where F is the target (e.g., scaled identity) and delta is the shrinkage intensity. Ledoit-Wolf (2004) derives the delta that minimizes expected squared Frobenius distance to the true covariance matrix, trading a little bias for a large variance reduction — yielding better-conditioned, invertible matrices and stable portfolio weights.

Note: the bundled script's shrunk_covariance implements a simplified shrinkage-intensity estimate, not the full Ledoit-Wolf estimator. For production work use sklearn.covariance.LedoitWolf.

Regression diagnostics (CAPM and factor models)

For the single-factor CAPM regression R_i - R_f = alpha + beta * (R_m - R_f) + epsilon:

  • beta = rho * sigma_i / sigma_m (market sensitivity); alpha is the risk-adjusted excess return.
  • In a single-factor regression, R^2 = rho^2.
  • Judge coefficients by t-statistics (t = coefficient / SE); with n - 2 df, |t| above roughly 2 indicates 5% significance. A positive alpha point estimate with |t| < 2 is not evidence of skill.
  • Adding regressors always raises R-squared; use adjusted R-squared, AIC/BIC, or cross-validation to guard against overfitting.
Bootstrap procedure

Non-parametric resampling for the sampling distribution of a statistic when analytical standard errors are unavailable (Sharpe ratio, alpha), the distribution is non-normal, or samples are small:

  1. From the original n observations, draw B resamples of size n with replacement (B = 1,000-10,000).
  2. Compute the statistic on each resample.
  3. Percentile method: the (1 - alpha) confidence interval is the alpha/2 and 1 - alpha/2 percentiles of the bootstrap distribution; the bootstrap standard error is the std of the B statistics.

Caveat: the i.i.d. bootstrap ignores autocorrelation and volatility clustering; use block bootstrap for serially dependent return series.

Standard Analysis Workflow

Given a return series, run this sequence:

  1. Descriptive stats — mean, volatility (n-1), skewness, excess kurtosis; annualize for reporting.
  2. Distribution checks — Jarque-Bera (mind the low-power caveat), inspect skew/kurtosis magnitudes and largest outliers; decide whether normal-based methods (parametric VaR, t-tests) are defensible.
  3. Covariance/correlation (multi-asset) — sample covariance and correlation matrices; if p is large relative to n, apply shrinkage before any optimization.
  4. Regression diagnostics — CAPM or factor regression; report alpha/beta with t-stats and R-squared; check residuals for structure.
  5. Bootstrap CIs — for statistics without clean analytical standard errors (Sharpe, alpha, drawdown), bootstrap confidence intervals rather than reporting bare point estimates.

Worked Examples

Show full SKILL.md (388 more words)Show less
Example 1: Descriptive Statistics and Normality Test

Given: 12 monthly returns (%): [2.1, -0.5, 1.8, -3.2, 4.5, 0.3, -1.1, 2.7, -0.8, 3.4, 1.2, -0.6]

Mean      = 9.8 / 12 = 0.8167% per month  (~9.8% annualized, simple x12)
s^2       = 52.977 / 11 = 4.816   ->   s = 2.195% per month
Ann. vol  = 2.195% * sqrt(12) = 7.60%
Skewness  = -0.045  (bias-corrected; near symmetric)
Ex. kurt  = -0.42   (bias-corrected; lighter tails than normal)

JB = (12/6) * ((-0.045)^2 + (-0.42)^2 / 4) = 0.09

JB = 0.09 < 5.99 (chi-squared 5% critical, df=2): fail to reject normality. With only 12 observations the test has very low power — this is not evidence that the returns are truly normal.

Example 2: CAPM Regression from Summary Statistics

Given: 24 monthly observations. Fund excess returns: mean 0.8%, std 4.2%. Market excess returns: mean 0.6%, std 3.8%. Correlation 0.85.

beta  = rho * sigma_i / sigma_m = 0.85 * 4.2 / 3.8 = 0.939
alpha = 0.8% - 0.939 * 0.6% = 0.236% per month (~2.84% annualized)
R^2   = rho^2 = 0.7225

Residual std = 4.2% * sqrt(1 - 0.7225) = 2.213%
SE(alpha) = 2.213% / sqrt(24) = 0.452%   ->  t(alpha) = 0.236 / 0.452 = 0.52
SE(beta)  = 2.213% / (3.8% * sqrt(23)) = 0.121  ->  t(beta) = 0.939 / 0.121 = 7.74

With 22 df, the 5% two-tailed critical t is 2.074. Beta is highly significant (7.74 >> 2.074); alpha is not significant (0.52 < 2.074) — despite the positive point estimate, the sample cannot distinguish it from zero.

Common Pitfalls

  • Using population variance instead of sample variance: always use n - 1 (Bessel's correction) when estimating from a sample.
  • Assuming normality when financial returns have fat tails: equity returns typically show negative skewness and positive excess kurtosis; normal-based models (standard VaR) underestimate tail risk. Use Student-t or non-parametric methods.
  • Ignoring non-stationarity: return distributions shift over time (regime changes, volatility clustering). Rolling-window estimation or GARCH may be more appropriate than full-sample statistics.
  • Overfitting with too many regressors: R-squared always rises with added factors; use adjusted R-squared, information criteria, or cross-validation.
  • Unstable covariance matrices with small samples: when p approaches or exceeds n, apply Ledoit-Wolf shrinkage or factor-based covariance models before optimizing.

Running the Script

scripts/statistics_fundamentals.py provides a StatisticsFundamentals class with static methods descriptive_stats, covariance_matrix, correlation_matrix, shrunk_covariance (simplified Ledoit-Wolf — see note above), ols_regression, rolling_regression, bootstrap_mean, and jarque_bera_test.

  • Run: uv run scripts/statistics_fundamentals.py (PEP 723 inline metadata resolves numpy and scipy), or python3 scripts/statistics_fundamentals.py with numpy/scipy installed.
  • Bare invocation (or --verify) prints a demo on synthetic data and asserts the Example 1 worked-example values above (mean 0.8167, std 2.195, JB 0.09 on the 12-month series), exiting nonzero on any mismatch.
  • --help lists the available methods and import usage.
  • For programmatic use, import rather than run: from statistics_fundamentals import StatisticsFundamentals, then call e.g. StatisticsFundamentals.descriptive_stats(...).

Cross-References

  • return-calculations (core plugin): Arithmetic and geometric mean returns, log returns for statistical modeling
  • time-value-of-money (core plugin): Discount rate estimation via CAPM regression; NPV and IRR calculations use statistical inputs
  • factor-investing (wealth-management plugin): Extends the single-factor CAPM/OLS regression to Fama-French multifactor models for alpha attribution and fund evaluation
  • financial-statements (wealth-management plugin): applies descriptive statistics and trend analysis to financial ratios and peer comparisons

© JoelLewis, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (scripts) in plugins/core/skills/statistics-fundamentals of JoelLewis/finance_skills.

  • SKILL.md
  • scripts/statistics_fundamentals.py

Open the folder on GitHubat commit 5c498ea

Compare with similar skills

Statistics Fundamentals next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Statistics Fundamentals compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Statistics Fundamentals this skillJoelLewis/finance_skills206—~2.2kAutomated safety check: PassMIT
Sandbox Benchvercel/next.js143k—~4.1kAutomated safety check: PassMIT
Statistical Analysisspacering-net/codeg3.9k3 repos~5kAutomated safety check: PassMIT
StatsmodelszLanqing/codex-claude-academic-skills4.7k15 repos~4.9kAutomated safety check: PassBSD-3-Clause
AI Daily DigestvigorX777/ai-daily-digest1.6k—~1.3kAutomated safety check: PassNone
Statistical Powerspacering-net/codeg3.9k1 repos~3.6kAutomated safety check: NotesMIT

Similar skills

  • Sandbox Bench

    vercel/next.js

    Official

    Benchmark React or Next.js changes on Vercel Sandbox VMs with paired A/B statistics: react PR/commit vs base, or Next.js PR/commit vs base, measured end-to-end through the bench/render-pipeline app…

    143k GitHub stars~4.1k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Statistical Analysis

    spacering-net/codeg

    Guided statistical analysis for research data - test selection, assumption checking, effect sizes, power analysis, Bayesian alternatives, and APA-formatted reporting.

    3.9k GitHub starsUsed in 3 repos~5k tokens
    Data & AnalyticsAuto-check passed
  • Statsmodels

    zLanqing/codex-claude-academic-skills

    Statistical models library for Python. An agent skill from zLanqing/codex-claude-academic-skills.

    4.7k GitHub starsUsed in 15 repos~4.9k tokens
    Data & AnalyticsAuto-check passed
  • AI Daily Digest

    vigorX777/ai-daily-digest

    Fetches RSS feeds from 90 top Hacker News blogs (curated by Karpathy), uses AI to score and filter articles, and generates a daily digest in Markdown with Chinese-translated titles, category…

    1.6k GitHub stars~1.3k tokensUpdated 7 mo ago
    Data & AnalyticsAuto-check passed
  • Statistical Power

    spacering-net/codeg

    Sample-size and statistical power calculations for planning studies.

    3.9k GitHub starsUsed in 1 repo~3.6k tokens
    Data & AnalyticsAuto-check: notes
  • Agent Session Monitor

    higress-group/higress

    Real-time agent conversation monitoring - monitors Higress access logs, aggregates conversations by session, tracks token usage.

    9.5k GitHub stars~3.3k tokensUpdated 2 days ago
    Data & AnalyticsAuto-check passed

More from JoelLewis/finance_skills

All 91 skills in this repo
  • Asset Allocation

    JoelLewis/finance_skills

    Determine how to distribute capital across asset classes using strategic and tactical allocation frameworks.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Bet Sizing

    JoelLewis/finance_skills

    Determine how much capital to allocate to individual positions within a portfolio.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Commodities

    JoelLewis/finance_skills

    Analyze commodity markets including futures curve dynamics, roll yield, and supply/demand fundamentals.

    206 GitHub stars~1.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Currencies And Fx

    JoelLewis/finance_skills

    Analyze currency markets, exchange rate mechanics, and FX risk management for international portfolios.

    206 GitHub stars~1.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Debt Management

    JoelLewis/finance_skills

    Provide frameworks for managing and paying off personal debt effectively.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Diversification

    JoelLewis/finance_skills

    Build diversified portfolios using correlation analysis, efficient frontier construction, and factor-based diversification.

    206 GitHub stars~2.3k tokensUpdated 2 mo ago
    Auto-check passed

Questions about Statistics Fundamentals

What does Statistics Fundamentals do?

Apply statistical methods to financial data including descriptive statistics, covariance estimation, regression, hypothesis testing, and resampling. Statistics Fundamentals is an agent skill from JoelLewis/finance_skills. Apply statistical methods to financial data including descriptive statistics, covariance estimation, regression, hypothesis testing, and resampling.

When should I use Statistics Fundamentals?

Statistics Fundamentals fits situations like: the user asks about return distributions; correlation between assets; building a covariance matrix; running a CAPM regression.

How do I install Statistics Fundamentals in Claude Code?

Run `npx skills add JoelLewis/finance_skills --skill statistics-fundamentals -a claude-code`. Or copy the skill folder (plugins/core/skills/statistics-fundamentals in JoelLewis/finance_skills) into .claude/skills/statistics-fundamentals in your project. Claude Code loads it when a task matches its description.

How do I install Statistics Fundamentals in Codex?

Run `npx skills add JoelLewis/finance_skills --skill statistics-fundamentals -a codex`. Or copy the skill folder (plugins/core/skills/statistics-fundamentals in JoelLewis/finance_skills) into .agents/skills/statistics-fundamentals in your project. Codex loads it when a task matches its description.

Can I use Statistics Fundamentals in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add JoelLewis/finance_skills --skill statistics-fundamentals -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/statistics-fundamentals, .gemini/skills/statistics-fundamentals, .github/skills/statistics-fundamentals and .opencode/skills/statistics-fundamentals in your project.

What does Statistics Fundamentals need to run?

Going by SKILL.md and its folder, Statistics Fundamentals needs Python for the scripts in its folder and the command-line tools its instructions call (uv and python3). Our summary lists: Python 3.

Does Statistics Fundamentals access the network?

SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Statistics Fundamentals safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Statistics Fundamentals use?

Statistics Fundamentals is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Statistics Fundamentals use?

About 2.2k tokens (SKILL.md is roughly 9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Statistics Fundamentals?

Skills that share tags, products or a category with Statistics Fundamentals: Sandbox Bench (vercel/next.js, 143k stars), Statistical Analysis (spacering-net/codeg, 3.9k stars), Statsmodels (zLanqing/codex-claude-academic-skills, 4.7k stars) and AI Daily Digest (vigorX777/ai-daily-digest, 1.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Statistics Fundamentals?

JoelLewis (a GitHub user) maintains it in JoelLewis/finance_skills, which has 206 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on July 18, 2026.

Source: JoelLewis/finance_skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.