Skip to content

fix(stats): use consistent population moments for DSR - #100

Merged
stefan-jansen merged 4 commits into
mainfrom
codex/dsr-population-moments
Oct 14, 2026
Merged

stefan-jansen merged 4 commits into
mainfrom
codex/dsr-population-moments

Conversation

@stefan-jansen

@stefan-jansen stefan-jansen commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Short return samples mixed population third/fourth moments with sample standard deviation, understating the skewness and kurtosis passed to DSR. Use population moments consistently for those two statistics while retaining sample standard deviation for Sharpe.

Refs #89. Keep that tracking issue open until all companion fixes land.

Current head: 2448ba3, based on main d7da592. Stable patch ID 9bb1068eb621b99cad88092d21608ce44df1da7e proves the focused diff is unchanged from the tested implementation below. Fresh current-head moments/statistics tests passed 169 cases (1 benchmark case deselected by configured markers); the full locked suite passed 5478 tests with 7 skips on Linux/Python 3.14.3. Ruff check/format, ty, all-file hooks, strict MkDocs, 9643 links/20 external destinations, and wheel/sdist build passed. Current-base hosted CI remains required.

Verification:

  • Base: 5f35459. On 30 deterministic t-distributed returns from np.random.default_rng(123), skewness differs from scipy.stats.skew by -0.027614087488468275 and Pearson kurtosis differs from scipy.stats.kurtosis(..., fisher=False) by -0.27326822992453614.
  • Reviewed head: d7f72d3. Both differences are zero. The public deflated_sharpe_ratio result also matches SciPy skewness and excess kurtosis.
  • Commands: uv run --locked pytest -n 0 tests/test_evaluation/test_moments.py tests/test_evaluation/test_stats.py::TestDeflatedSharpeRatioRawReturns -q. The focused moment run passed 35 cases and the raw-return DSR class passed 20 cases before adding its new public regression.
  • Full suite at the reviewed head: 5473 passed, 7 skipped. Ruff lint/format, ty, pre-commit --all-files, strict MkDocs, and wheel/sdist build passed.
  • Cross-platform CI on this PR is still required before merge.

Compatibility: short-sample skewness, kurtosis, and downstream DSR inference change numerically. Sharpe remains defined using sample standard deviation. This is a correction to mixed moment divisors, not a change to the separate unbiased distribution-moments API.

Attribution: preserves original Git authorship for @quantum-like's PR #90 commit 7237b26. Codex added a regression through public deflated_sharpe_ratio, split the branch, and ran checks. AI assistance includes the original Cursor Agent commit and Codex's review, test, and this description. Maintainer review and accountability remain required.

cursoragent and others added 3 commits October 13, 2026 12:26
Fisher skewness and Pearson kurtosis were divided by the sample standard
deviation. Their numerators already use the 1/n central moments, so short
samples understated both inputs to the deflated Sharpe ratio.

Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 20:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants