Skip to content

已弃用 (2026-05-25) —— 该算子是 Layer-1 变换、非 Layer-0 原子输入,已并入 correlation_matrix_v1。保留作历史。

做什么(One-liner)

两两皮尔逊相关矩阵(numpy.corrcoef 包装)。库级 primitive,portfolio / regime / criticality 核心依赖。

怎么用

python
from services.algo.statistics import correlation_matrix
correlation_matrix({
    "SPY": [1, 2, 3, 4, 5],
    "TLT": [5, 4, 3, 2, 1],
})
# → {"SPY": {"SPY": 1.0, "TLT": -1.0}, "TLT": {"SPY": -1.0, "TLT": 1.0}}

核心公式

ρ_{ij} = Cov(X_i, X_j) / (σ_i × σ_j)   # numpy.corrcoef

假设与适用场景

假设:同步 + 同长度 + n≥2。

适用:portfolio 协方差、regime、herd-risk criticality。

不适用:非线性、pairwise 缺失、高维低样本(用 Ledoit-Wolf)。

已知局限

  1. Pearson 线性假设
  2. 无 pairwise complete
  3. 厚尾低估

参考文献

Pearson (1895) 原始 + Ledoit-Wolf (2004) shrinkage 改进。

Golden Test

tests/golden/fixtures/tier1/correlation_matrix/,1e-12,2026-04-20 passing。

Changelog

  • 1.0.0 (2026-04-20) — 首次 Active

Verifiable intelligence for the decisions that demand scrutiny.