math-skill 2.1.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en-US.md +165 -198
- package/README.md +165 -198
- package/agents/math-critic.en.md +28 -26
- package/agents/math-critic.md +33 -33
- package/commands/ask.en.md +10 -0
- package/commands/ask.md +3 -10
- package/design-patterns/attention/equivariant-attention.en.md +72 -0
- package/design-patterns/attention/equivariant-attention.md +72 -0
- package/design-patterns/attention/geometry-aware-attention.en.md +73 -0
- package/design-patterns/attention/geometry-aware-attention.md +72 -0
- package/design-patterns/attention/information-bottleneck-attention.en.md +72 -0
- package/design-patterns/attention/information-bottleneck-attention.md +72 -0
- package/design-patterns/attention/projection-attention.en.md +68 -0
- package/design-patterns/attention/projection-attention.md +68 -0
- package/design-patterns/attention/spectral-attention.en.md +71 -0
- package/design-patterns/attention/spectral-attention.md +71 -0
- package/design-patterns/compression/leverage-score-selection.en.md +71 -0
- package/design-patterns/compression/leverage-score-selection.md +71 -0
- package/design-patterns/compression/low-rank-kv-cache.en.md +60 -0
- package/design-patterns/compression/low-rank-kv-cache.md +60 -0
- package/design-patterns/compression/spectral-token-pruning.en.md +61 -0
- package/design-patterns/compression/spectral-token-pruning.md +61 -0
- package/design-patterns/compression/topology-preserving-compression.en.md +64 -0
- package/design-patterns/compression/topology-preserving-compression.md +64 -0
- package/design-patterns/loss/constraint-penalty.en.md +67 -0
- package/design-patterns/loss/constraint-penalty.md +78 -0
- package/design-patterns/loss/contrastive-loss.en.md +59 -0
- package/design-patterns/loss/contrastive-loss.md +68 -0
- package/design-patterns/loss/information-bottleneck-loss.en.md +69 -0
- package/design-patterns/loss/information-bottleneck-loss.md +74 -0
- package/design-patterns/loss/orthogonality-loss.en.md +56 -0
- package/design-patterns/loss/orthogonality-loss.md +60 -0
- package/design-patterns/loss/variational-loss.en.md +61 -0
- package/design-patterns/loss/variational-loss.md +71 -0
- package/design-patterns/representation/equivariant-split.en.md +87 -0
- package/design-patterns/representation/equivariant-split.md +89 -0
- package/design-patterns/representation/manifold-representation.en.md +85 -0
- package/design-patterns/representation/manifold-representation.md +87 -0
- package/design-patterns/representation/shared-private-decomposition.en.md +84 -0
- package/design-patterns/representation/shared-private-decomposition.md +86 -0
- package/design-patterns/representation/subspace-alignment.en.md +90 -0
- package/design-patterns/representation/subspace-alignment.md +92 -0
- package/design-patterns/routing/graph-routing.en.md +79 -0
- package/design-patterns/routing/graph-routing.md +81 -0
- package/design-patterns/routing/moe-routing.en.md +85 -0
- package/design-patterns/routing/moe-routing.md +87 -0
- package/design-patterns/routing/optimal-transport-routing.en.md +68 -0
- package/design-patterns/routing/optimal-transport-routing.md +72 -0
- package/design-patterns/routing/spectral-clustering-routing.en.md +88 -0
- package/design-patterns/routing/spectral-clustering-routing.md +90 -0
- package/knowledge-base/differential-geometry/connection.en.md +51 -0
- package/knowledge-base/differential-geometry/connection.md +51 -0
- package/knowledge-base/differential-geometry/curvature.en.md +49 -0
- package/knowledge-base/differential-geometry/curvature.md +49 -0
- package/knowledge-base/differential-geometry/geodesic.en.md +51 -0
- package/knowledge-base/differential-geometry/geodesic.md +51 -0
- package/knowledge-base/differential-geometry/manifold.en.md +47 -0
- package/knowledge-base/differential-geometry/manifold.md +47 -0
- package/knowledge-base/differential-geometry/metric-tensor.en.md +50 -0
- package/knowledge-base/differential-geometry/metric-tensor.md +50 -0
- package/knowledge-base/differential-geometry/tangent-space.en.md +48 -0
- package/knowledge-base/differential-geometry/tangent-space.md +48 -0
- package/knowledge-base/information-geometry/fisher-metric.en.md +56 -0
- package/knowledge-base/information-geometry/fisher-metric.md +56 -0
- package/knowledge-base/information-geometry/natural-gradient.en.md +54 -0
- package/knowledge-base/information-geometry/natural-gradient.md +54 -0
- package/knowledge-base/lie-theory/equivariance.en.md +54 -0
- package/knowledge-base/lie-theory/equivariance.md +54 -0
- package/knowledge-base/lie-theory/group-action.en.md +51 -0
- package/knowledge-base/lie-theory/group-action.md +51 -0
- package/knowledge-base/lie-theory/lie-algebra.en.md +51 -0
- package/knowledge-base/lie-theory/lie-algebra.md +51 -0
- package/knowledge-base/lie-theory/lie-group.en.md +51 -0
- package/knowledge-base/lie-theory/lie-group.md +51 -0
- package/knowledge-base/lie-theory/representation.en.md +52 -0
- package/knowledge-base/lie-theory/representation.md +52 -0
- package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +49 -0
- package/knowledge-base/matrix-analysis/low-rank-approximation.md +49 -0
- package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +49 -0
- package/knowledge-base/matrix-analysis/matrix-perturbation.md +49 -0
- package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +50 -0
- package/knowledge-base/matrix-analysis/positive-semidefinite.md +50 -0
- package/knowledge-base/matrix-analysis/projection.en.md +47 -0
- package/knowledge-base/matrix-analysis/projection.md +47 -0
- package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +48 -0
- package/knowledge-base/matrix-analysis/spectral-decomposition.md +48 -0
- package/knowledge-base/optimization/constrained-optimization.en.md +53 -0
- package/knowledge-base/optimization/constrained-optimization.md +53 -0
- package/knowledge-base/optimization/convex-optimization.en.md +50 -0
- package/knowledge-base/optimization/convex-optimization.md +50 -0
- package/knowledge-base/optimization/lagrangian-duality.en.md +50 -0
- package/knowledge-base/optimization/lagrangian-duality.md +50 -0
- package/knowledge-base/optimization/proximal-method.en.md +52 -0
- package/knowledge-base/optimization/proximal-method.md +52 -0
- package/knowledge-base/optimization/riemannian-optimization.en.md +51 -0
- package/knowledge-base/optimization/riemannian-optimization.md +51 -0
- package/knowledge-base/overview.en.md +29 -218
- package/knowledge-base/overview.md +29 -220
- package/knowledge-base/probability/concentration-inequality.en.md +45 -0
- package/knowledge-base/probability/concentration-inequality.md +45 -0
- package/knowledge-base/probability/entropy.en.md +47 -0
- package/knowledge-base/probability/entropy.md +47 -0
- package/knowledge-base/probability/fisher-information.en.md +48 -0
- package/knowledge-base/probability/fisher-information.md +48 -0
- package/knowledge-base/probability/information-bottleneck.en.md +49 -0
- package/knowledge-base/probability/information-bottleneck.md +49 -0
- package/knowledge-base/probability/kl-divergence.en.md +51 -0
- package/knowledge-base/probability/kl-divergence.md +51 -0
- package/knowledge-base/topology/euler-characteristic.en.md +54 -0
- package/knowledge-base/topology/euler-characteristic.md +54 -0
- package/knowledge-base/topology/fundamental-group.en.md +52 -0
- package/knowledge-base/topology/fundamental-group.md +52 -0
- package/knowledge-base/topology/persistent-homology.en.md +54 -0
- package/knowledge-base/topology/persistent-homology.md +54 -0
- package/lenses/algorithmic.en.md +49 -0
- package/lenses/algorithmic.md +49 -0
- package/lenses/axiomatization.en.md +48 -0
- package/lenses/axiomatization.md +48 -0
- package/lenses/categorical.en.md +48 -0
- package/lenses/categorical.md +48 -0
- package/lenses/causal.en.md +49 -0
- package/lenses/causal.md +49 -0
- package/lenses/duality.en.md +47 -0
- package/lenses/duality.md +47 -0
- package/lenses/game.en.md +50 -0
- package/lenses/game.md +50 -0
- package/lenses/geometric.en.md +53 -0
- package/lenses/geometric.md +53 -0
- package/lenses/local-to-global.en.md +52 -0
- package/lenses/local-to-global.md +52 -0
- package/lenses/perturbation.en.md +51 -0
- package/lenses/perturbation.md +51 -0
- package/lenses/probabilistic.en.md +48 -0
- package/lenses/probabilistic.md +48 -0
- package/lenses/projection.en.md +50 -0
- package/lenses/projection.md +50 -0
- package/lenses/spectral.en.md +52 -0
- package/lenses/spectral.md +52 -0
- package/lenses/symmetry.en.md +49 -0
- package/lenses/symmetry.md +49 -0
- package/lenses/topological.en.md +48 -0
- package/lenses/topological.md +48 -0
- package/lenses/variational.en.md +48 -0
- package/lenses/variational.md +48 -0
- package/package.json +9 -3
- package/references/agentic-workflow.en.md +1 -1
- package/references/agentic-workflow.md +1 -1
- package/references/books/abstract-algebra.en.md +124 -0
- package/references/books/abstract-algebra.md +22 -22
- package/references/books/algebraic-geometry-rising-sea.en.md +171 -0
- package/references/books/algebraic-geometry-rising-sea.md +11 -11
- package/references/books/differential-geometry.en.md +140 -0
- package/references/books/differential-geometry.md +19 -19
- package/references/books/matrix-analysis.en.md +146 -0
- package/references/books/matrix-analysis.md +10 -10
- package/references/books/micro-lie-theory.en.md +116 -0
- package/references/books/micro-lie-theory.md +17 -17
- package/references/books/optimization-ml.en.md +163 -0
- package/references/books/optimization-ml.md +7 -8
- package/references/books/smooth-manifolds.en.md +105 -0
- package/references/books/smooth-manifolds.md +14 -14
- package/references/gpu-friendly-math.en.md +23 -10
- package/references/gpu-friendly-math.md +17 -4
- package/references/inspiration.en.md +1 -1
- package/references/inspiration.md +2 -2
- package/skills/math-research-activator/SKILL.en.md +195 -114
- package/skills/math-research-activator/SKILL.md +194 -119
- package/skills/math-research-activator/original-texts.en.md +9 -9
- package/skills/math-research-activator/original-texts.md +11 -11
- package/commands/abstraction.md +0 -11
- package/commands/algorithmic-thinking.md +0 -11
- package/commands/axiomatization.md +0 -11
- package/commands/causal-inference.md +0 -11
- package/commands/discrete-combinatorial.md +0 -11
- package/commands/game-theory.md +0 -11
- package/commands/induction-analogy.md +0 -11
- package/commands/information-theory.md +0 -11
- package/commands/logic-deduction.md +0 -11
- package/commands/modeling.md +0 -11
- package/commands/optimization.md +0 -11
- package/commands/probability-statistics.md +0 -11
- package/commands/symmetry-invariance.md +0 -11
- package/commands/topological-thinking.md +0 -11
- package/commands/transformation.md +0 -11
- package/skills/abstraction/SKILL.en.md +0 -117
- package/skills/abstraction/SKILL.md +0 -121
- package/skills/abstraction/original-texts.en.md +0 -163
- package/skills/abstraction/original-texts.md +0 -175
- package/skills/algorithmic-thinking/SKILL.en.md +0 -132
- package/skills/algorithmic-thinking/SKILL.md +0 -138
- package/skills/algorithmic-thinking/original-texts.en.md +0 -253
- package/skills/algorithmic-thinking/original-texts.md +0 -256
- package/skills/axiomatization/SKILL.en.md +0 -144
- package/skills/axiomatization/SKILL.md +0 -151
- package/skills/axiomatization/original-texts.en.md +0 -154
- package/skills/axiomatization/original-texts.md +0 -160
- package/skills/causal-inference/SKILL.en.md +0 -147
- package/skills/causal-inference/SKILL.md +0 -151
- package/skills/causal-inference/original-texts.en.md +0 -136
- package/skills/causal-inference/original-texts.md +0 -167
- package/skills/discrete-combinatorial/SKILL.en.md +0 -124
- package/skills/discrete-combinatorial/SKILL.md +0 -131
- package/skills/discrete-combinatorial/original-texts.en.md +0 -184
- package/skills/discrete-combinatorial/original-texts.md +0 -185
- package/skills/game-theory/SKILL.en.md +0 -117
- package/skills/game-theory/SKILL.md +0 -123
- package/skills/game-theory/original-texts.en.md +0 -131
- package/skills/game-theory/original-texts.md +0 -131
- package/skills/induction-analogy/SKILL.en.md +0 -145
- package/skills/induction-analogy/SKILL.md +0 -152
- package/skills/induction-analogy/original-texts.en.md +0 -140
- package/skills/induction-analogy/original-texts.md +0 -154
- package/skills/information-theory/SKILL.en.md +0 -134
- package/skills/information-theory/SKILL.md +0 -140
- package/skills/information-theory/original-texts.en.md +0 -127
- package/skills/information-theory/original-texts.md +0 -127
- package/skills/logic-deduction/SKILL.en.md +0 -130
- package/skills/logic-deduction/SKILL.md +0 -135
- package/skills/logic-deduction/original-texts.en.md +0 -160
- package/skills/logic-deduction/original-texts.md +0 -173
- package/skills/modeling/SKILL.en.md +0 -135
- package/skills/modeling/SKILL.md +0 -139
- package/skills/modeling/original-texts.en.md +0 -162
- package/skills/modeling/original-texts.md +0 -165
- package/skills/optimization/SKILL.en.md +0 -129
- package/skills/optimization/SKILL.md +0 -135
- package/skills/optimization/original-texts.en.md +0 -167
- package/skills/optimization/original-texts.md +0 -168
- package/skills/probability-statistics/SKILL.en.md +0 -146
- package/skills/probability-statistics/SKILL.md +0 -151
- package/skills/probability-statistics/original-texts.en.md +0 -191
- package/skills/probability-statistics/original-texts.md +0 -193
- package/skills/symmetry-invariance/SKILL.en.md +0 -135
- package/skills/symmetry-invariance/SKILL.md +0 -139
- package/skills/symmetry-invariance/original-texts.en.md +0 -206
- package/skills/symmetry-invariance/original-texts.md +0 -221
- package/skills/topological-thinking/SKILL.en.md +0 -124
- package/skills/topological-thinking/SKILL.md +0 -128
- package/skills/topological-thinking/original-texts.en.md +0 -134
- package/skills/topological-thinking/original-texts.md +0 -164
- package/skills/transformation/SKILL.en.md +0 -120
- package/skills/transformation/SKILL.md +0 -124
- package/skills/transformation/original-texts.en.md +0 -204
- package/skills/transformation/original-texts.md +0 -216
package/skills/modeling/SKILL.md
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: modeling
|
|
3
|
-
description: |
|
|
4
|
-
触发:当需要将现实问题转化为数学问题(现实→数学→解释)、构建预测/解释模型、进行量纲分析与模型选择、为算法/算子/结构建立可计算模型时调用。
|
|
5
|
-
English: Trigger when translating real-world problems into mathematics (reality→math→interpretation), building predictive/explanatory models, performing dimensional analysis and model selection, or establishing computable models for algorithms/operators/structures.
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
> **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `SKILL.en.md`,按其操作规程以英文输出;中文消息则继续使用本文件。
|
|
9
|
-
|
|
10
|
-
# 🌉 建模思想 / Modeling
|
|
11
|
-
|
|
12
|
-
> "将现实世界的问题转化为数学问题,通过求解数学问题来解释和预测现实。所有模型都是错的,但有些是有用的。"
|
|
13
|
-
> "Transforming real-world problems into mathematical problems, solving them mathematically to explain and predict reality. All models are wrong, but some are useful."
|
|
14
|
-
>
|
|
15
|
-
> —— 应用数学、数学建模 / Applied Mathematics, Mathematical Modeling
|
|
16
|
-
|
|
17
|
-
## 核心原则 / Core Principle
|
|
18
|
-
|
|
19
|
-
**模型是现实的简化表示,不是现实本身。一个好模型不是"真实"的模型,而是在其适用范围内能做出准确预测的模型。**
|
|
20
|
-
|
|
21
|
-
建模的黄金循环:① **现实问题→数学问题**(翻译);② **数学问题→数学解**(求解);③ **数学解→现实解释**(回译);④ **现实解释→实验验证**(检验)。
|
|
22
|
-
|
|
23
|
-
> **数学形式化 / Mathematical Formalization**
|
|
24
|
-
>
|
|
25
|
-
> **量纲分析与 Buckingham Pi 定理 / Dimensional Analysis & Buckingham Pi Theorem**:建方程前必须检查量纲一致性。若系统有 $n$ 个物理量涉及 $m$ 个基本量纲,可构造 $k=n-m$ 个无量纲 Pi 项,减少变量、简化方程;量纲不一致的方程物理上不可接受。
|
|
26
|
-
>
|
|
27
|
-
> **模型规格 / Model Specification**:设系统输出 $y$,输入 $x_1,\dots,x_p$,模型 $y=f(x_1,\dots,x_p;\theta)+\varepsilon$,其中 $f$ 为模型函数、$\theta$ 为参数向量、$\varepsilon$ 为误差项。模型选择即在候选集 $\{f_1,f_2,\dots\}$ 中选出偏差-方差最优的 $f$。
|
|
28
|
-
|
|
29
|
-
## GPU 友好性 / GPU-Friendliness(横切检查)
|
|
30
|
-
|
|
31
|
-
当模型用于**算法/算子/训练设计**时,模型选择与参数化直接决定 GPU 可行性——过 `../../references/gpu-friendly-math.md` 八维门:
|
|
32
|
-
|
|
33
|
-
- **线性/可 GEMM 化参数化**:$y=f(x;\theta)$ 中 $f$ 表为稠密张量代数或矩阵乘链(线性回归、MLP)→ 友好,吃满 Tensor Core。
|
|
34
|
-
- **低秩参数化**:$\theta$ 用低秩/块结构代替稠密 → 显存友好、可压缩(见 `../../references/books/matrix-analysis.md`)。
|
|
35
|
-
- **算子分裂/块并行**:PDE/ODE 模型按空间/时间分块、串行递推改并行扫描 → 可改造。
|
|
36
|
-
- **反模式**:模型需 $O(n^2)$ 稠密全局算子(朴素全注意力)、数据相关分支/标量循环、病态需 fp64、不可微需离散搜索 → "美但不可算",改选可张量化、可融合、数值稳定的等价参数化。
|
|
37
|
-
|
|
38
|
-
八维最低判定(正式术语):**张量化**看模型方程能否批量求值;**GEMM 可映射**看参数化是否可写成矩阵乘/卷积/低秩因子;**复杂度**看状态维、时间步、交互项增长;**显存与 KV-Cache**看隐状态、激活、缓存能否压缩;**低精度稳定**看方程是否病态或需 fp64;**并行与通信**看动态系统能否分块/scan;**稀疏结构**看耦合图是否结构化;**算子融合**看模型更新与 loss 是否可融合。
|
|
39
|
-
|
|
40
|
-
> 配合 `../../references/books/optimization-ml.md`(模型参数化与训练)、`matrix-analysis.md`(低秩、条件数、压缩)。
|
|
41
|
-
|
|
42
|
-
## 不适用场景 / When NOT to Use
|
|
43
|
-
|
|
44
|
-
- **问题无法量化或结构化**——建模需要可定义的变量和关系。
|
|
45
|
-
- **只需要定性理解**(如"这个现象大概怎么回事")——建模会过度精确。
|
|
46
|
-
- **缺乏基本数据**——没有数据的模型只是猜测。
|
|
47
|
-
|
|
48
|
-
## 何时使用 / When to Use
|
|
49
|
-
|
|
50
|
-
- 需要将现实问题用数学语言精确表述(现实→数学→解释)。
|
|
51
|
-
- 构建预测/解释模型以解读实验数据或预测新现象。
|
|
52
|
-
- 理解复杂系统中各因素的相互作用与敏感度。
|
|
53
|
-
- 进行量纲分析、模型选择(AIC/BIC/CV)与敏感度分析。
|
|
54
|
-
- **为算法/算子/结构建立可计算模型**,并评估其参数化的 GPU 可行性。
|
|
55
|
-
|
|
56
|
-
## 方法流程 / Method
|
|
57
|
-
|
|
58
|
-
### 第一步:明确现实问题
|
|
59
|
-
用最清晰的语言描述要解决的问题。关键:系统的**输入**是什么?**输出**是什么?**目标**是预测、解释还是优化?方向不清,建模即失准。
|
|
60
|
-
|
|
61
|
-
### 第二步:做出假设
|
|
62
|
-
建模中最关键也最危险的一步。所有模型都需简化,但必须**明确记录每一个假设**:哪些因素重要、哪些可忽略?系统是确定性还是随机?静态还是动态?变量关系线性还是非线性?每个假设都要有依据。
|
|
63
|
-
|
|
64
|
-
### 第三步:建立数学结构 / 量纲分析
|
|
65
|
-
根据假设选择数学框架:
|
|
66
|
-
|
|
67
|
-
| 现象特征 | 数学框架 |
|
|
68
|
-
|---|---|
|
|
69
|
-
| 变量间因果关系 | 微分/差分方程 ODE/PDE |
|
|
70
|
-
| 空间分布与传播 | 偏微分方程(热传导、波动、扩散)|
|
|
71
|
-
| 离散对象的关系 | 图论 |
|
|
72
|
-
| 不确定性下的决策 | 概率模型 |
|
|
73
|
-
| 资源分配 | 优化模型 |
|
|
74
|
-
| 群体行为与交互 | 统计模型 / 马尔可夫链 / Agent-based |
|
|
75
|
-
| 分类与预测 | 函数逼近 / 回归 |
|
|
76
|
-
|
|
77
|
-
建方程前必须检查量纲一致性,构造 $k=n-m$ 个无量纲 Pi 项以减少变量、简化方程;量纲不一致的方程物理上不可接受。
|
|
78
|
-
|
|
79
|
-
### 第四步:求解
|
|
80
|
-
用数学方法求解模型:**解析解**(精确但可能不存在)、**数值解**(近似但总能得到)、**定性分析**(不求具体解,只求性质如稳定性、单调性)。
|
|
81
|
-
|
|
82
|
-
### 第五步:解释与验证
|
|
83
|
-
将数学解翻译回现实语言;与已有数据或实验结果对比;做 sanity check 检验预测是否合理。与现实不符的结论无论多"漂亮"都无效。
|
|
84
|
-
|
|
85
|
-
### 第六步:敏感度分析与模型选择
|
|
86
|
-
**敏感度分析**:若某参数小扰动导致输出大幅变化,则为敏感参数,需重点关注其取值精度。
|
|
87
|
-
**偏差-方差权衡**:简单模型偏差高、方差低(欠拟合);复杂模型偏差低、方差高(过拟合);最优模型在两者间平衡。
|
|
88
|
-
**模型选择准则**:AIC $= -2\log L + 2k$(倾向略复杂,适合预测);BIC $= -2\log L + k\log n$(惩罚更重,倾向简约,适合解释);交叉验证(CV)评估样本外预测性能、防过拟合。
|
|
89
|
-
|
|
90
|
-
### 第七步:迭代与改进
|
|
91
|
-
模型几乎总需改进。若预测与事实不符:哪个假设出了问题?是否需要增加新因素?是否需要改变数学框架?与现实不符时不是放弃建模,而是修正模型。
|
|
92
|
-
|
|
93
|
-
### 第八步:适用范围声明
|
|
94
|
-
明确标注模型在什么条件下有效、什么条件下失效。所有模型都有边界——适用范围声明是模型的"保质期标签",是防止误用的关键。
|
|
95
|
-
|
|
96
|
-
## 常见错误 / Common Errors
|
|
97
|
-
|
|
98
|
-
| 错误 / Error | 批评 / Critique | 正确做法 / Correct Approach |
|
|
99
|
-
|---|---|---|
|
|
100
|
-
| 过度拟合 | 模型太复杂,拟合了噪声而非信号 | 用奥卡姆剃刀:如无必要勿增实体 |
|
|
101
|
-
| 欠拟合 | 模型太简单,无法捕捉关键现象 | 检查残差模式,识别缺失因素 |
|
|
102
|
-
| 忽略假设的合理性 | 假设只为数学方便而非现实合理 | 每个假设都要有现实依据 |
|
|
103
|
-
| 外推超出适用范围 | 模型只在某范围内有效,超出失效 | 明确标注模型适用范围 |
|
|
104
|
-
| 把相关性当因果性 | 模型中的关系≠因果关系 | 区分描述性模型与因果模型 |
|
|
105
|
-
| 忘记验证 | 建完模型直接用,不检验预测 | 必须用独立数据验证 |
|
|
106
|
-
| 忽略量纲一致性 | 方程两侧量纲不匹配,物理不可接受 | 建方程前做量纲分析,构造无量纲 Pi 项 |
|
|
107
|
-
| 仅用样本内拟合选模型 | 样本内误差低估真实预测误差 | 用 AIC/BIC 或交叉验证评估样本外性能 |
|
|
108
|
-
| 忽略敏感度分析 | 不知哪些参数驱动结果 | 对关键参数做敏感度分析,重点关注敏感参数 |
|
|
109
|
-
| 混淆验证与模型选择 | 验证检验给定模型;选择在候选间比较 | 先用 AIC/BIC/CV 选模型,再用独立数据验证 |
|
|
110
|
-
| 模型过度复杂→不可算 | 参数化无法张量化/GEMM 化,$O(n^2)$ 显存爆炸 | 选可张量化、可融合、数值稳定的等价参数化,过 GPU 八维门 |
|
|
111
|
-
|
|
112
|
-
## 操作规程 / Operating Procedure
|
|
113
|
-
|
|
114
|
-
当本 skill 被触发时,输出必须包含:
|
|
115
|
-
|
|
116
|
-
1. **问题定义**:用一句话描述要解决的现实问题
|
|
117
|
-
2. **假设清单**:列出 `[假设N]: [内容](合理性:高/中/低)`
|
|
118
|
-
3. **量纲检查**:对关键物理量做量纲分析,构造无量纲 Pi 项
|
|
119
|
-
4. **模型选择**:`[框架]: [选择] 因为 [理由]`
|
|
120
|
-
5. **变量定义**:定义所有变量、参数及其物理意义
|
|
121
|
-
6. **求解方案**:说明求解方法(解析/数值/定性)
|
|
122
|
-
7. **敏感度分析**:识别敏感参数,评估其对输出的影响
|
|
123
|
-
8. **模型选择准则**:若有候选模型,用 AIC/BIC/CV 比较并选出最优
|
|
124
|
-
9. **验证计划**:如何检验模型的有效性?
|
|
125
|
-
10. **适用范围**:明确标注模型在什么条件下有效、什么条件下失效
|
|
126
|
-
11. **[GPU 可行性]**(若用于算法/算子/结构):模型参数化是否可张量化/GEMM 化、复杂度与显存是否可接受,过 `../../references/gpu-friendly-math.md` 八维门,标注友好/可改造/不友好 + 改造建议。
|
|
127
|
-
|
|
128
|
-
**输出不得只给分析而无结论。**
|
|
129
|
-
|
|
130
|
-
## 与其他 skill 的关系 / Relations to Other Skills
|
|
131
|
-
|
|
132
|
-
- **公理化思想**:模型的假设类似于公理,需要检验相容性。
|
|
133
|
-
- **抽象化思想**:建模是抽象化的应用——从现实抽象为数学结构。
|
|
134
|
-
- **优化思想**:很多模型的目标函数就是优化问题。
|
|
135
|
-
- **概率与统计**:不确定性建模需要概率论工具。
|
|
136
|
-
- **变换思想**:模型的求解常常需要变换到更容易处理的表示。
|
|
137
|
-
- **算法思想**:计算模型(agent-based、元胞自动机)将算法作为建模框架。
|
|
138
|
-
- **因果推断思想**:因果模型(DAG、结构因果模型)明确区分因果与相关。
|
|
139
|
-
- **现代数学激活**:`../../references/books/smooth-manifolds.md`(流形约束/隐空间几何)、`../../references/books/differential-geometry.md`(度量/曲率)、`../../references/books/optimization-ml.md`(参数化与训练)。
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
# Mathematical Sources and Classic Texts
|
|
2
|
-
|
|
3
|
-
## Newton's *Principia Mathematica* (1687)
|
|
4
|
-
|
|
5
|
-
> "The same effects of nature must always be assigned to the same causes."
|
|
6
|
-
|
|
7
|
-
**The most important achievement in the history of mathematical modeling**: Newton unified celestial and terrestrial motion within a single mathematical framework — the law of universal gravitation F = GMm/r² and the three laws of motion. This was humanity's first systematic use of mathematical models to precisely describe the physical world, marking the birth of scientific modeling. The *Principia* established the methodological paradigm of "mathematical model → physical prediction → experimental verification," which remains the foundation of all modeling work to this day.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Fourier's Heat Equation (1822)
|
|
12
|
-
|
|
13
|
-
> ∂u/∂t = κ ∇²u
|
|
14
|
-
|
|
15
|
-
In *Théorie analytique de la chaleur*, Fourier proposed a mathematical model for heat diffusion and, in doing so, invented Fourier analysis — the method of decomposing arbitrary functions into trigonometric series. This modeling achievement has a twofold significance: it provided a precise mathematical description of heat conduction, and it gave rise to the entire field of harmonic analysis. The Fourier transform remains a core tool in signal processing, quantum mechanics, image compression, and many other domains.
|
|
16
|
-
|
|
17
|
-
**Modeling insight**: The new mathematics invented to solve a modeling problem often has a more profound and lasting impact than the original model itself.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Maxwell's Equations (1865)
|
|
22
|
-
|
|
23
|
-
> ∇·E = ρ/ε₀, ∇×E = -∂B/∂t
|
|
24
|
-
> ∇·B = 0, ∇×B = μ₀J + μ₀ε₀∂E/∂t
|
|
25
|
-
|
|
26
|
-
Maxwell unified electricity and magnetism into four partial differential equations, and from the mathematical model alone predicted the existence of electromagnetic waves — a prediction later confirmed experimentally by Hertz. This is one of the most brilliant examples in the history of modeling: the discovery of an entirely new physical phenomenon through pure mathematical deduction. The equations also imply the speed of light c = 1/√(μ₀ε₀), subsuming optics into electromagnetic theory — arguably the pinnacle of unification in modeling.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Lotka-Volterra Predator-Prey Model (1925-1926)
|
|
31
|
-
|
|
32
|
-
The classical population dynamics model:
|
|
33
|
-
|
|
34
|
-
> dx/dt = αx - βxy (prey growth - predation)
|
|
35
|
-
> dy/dt = δxy - γy (predator growth - natural death)
|
|
36
|
-
|
|
37
|
-
**Modeling insight**: Through two simple differential equations, this model successfully explains the periodic oscillations observed in predator and prey populations in nature. It is the epitome of a "good model" — simple yet useful.
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Kermack-McKendrick SIR Epidemic Model (1927)
|
|
42
|
-
|
|
43
|
-
> dS/dt = -βSI (decrease in susceptibles)
|
|
44
|
-
> dI/dt = βSI - γI (change in infected)
|
|
45
|
-
> dR/dt = γI (increase in recovered)
|
|
46
|
-
|
|
47
|
-
**Modeling insight**: The basic reproduction number R₀ = β/γ determines whether an epidemic will take off. Kermack and McKendrick first proposed this model in their 1927 paper "A Contribution to the Mathematical Theory of Epidemics," laying the theoretical foundation for mathematical modeling of infectious diseases. This simple model was widely deployed during the COVID-19 pandemic, demonstrating the enduring value of classical models.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Buckingham Pi Theorem (1914)
|
|
52
|
-
|
|
53
|
-
> If a physical relationship involves n variables with k independent dimensions, the relationship can be reduced to one among (n-k) dimensionless Π groups.
|
|
54
|
-
|
|
55
|
-
**Modeling insight**: The Buckingham Pi theorem formalizes dimensional analysis, an extremely important simplification tool in modeling. It tells us that any physical model can be cast in dimensionless form, thereby reducing the number of parameters and revealing essential structure. For example, the Reynolds number Re = ρvL/μ in fluid mechanics is a single Π quantity that unifies countless seemingly different flow regimes.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## Turing's Reaction-Diffusion Model (1952)
|
|
60
|
-
|
|
61
|
-
> ∂u/∂t = D_u ∇²u + f(u,v)
|
|
62
|
-
> ∂v/∂t = D_v ∇²v + g(u,v)
|
|
63
|
-
|
|
64
|
-
In his paper "The Chemical Basis of Morphogenesis," Turing proved that two chemical substances diffusing at different rates and interacting can generate stable spatial patterns — spots, stripes, spirals — from an initially uniform state. This is a mathematical model of morphogenesis, explaining a wide range of phenomena from leopard spots to seashell patterns.
|
|
65
|
-
|
|
66
|
-
**Modeling insight**: Mathematical models can explain "how order emerges from disorder" — no pre-existing pattern is required; patterns arise spontaneously from the dynamics of the equations alone. Turing thereby founded the theory of pattern formation.
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Lorenz System (1963)
|
|
71
|
-
|
|
72
|
-
> dx/dt = σ(y - x)
|
|
73
|
-
> dy/dt = x(ρ - y) - xz
|
|
74
|
-
> dz/dt = xy - βz
|
|
75
|
-
|
|
76
|
-
While numerically simulating an atmospheric convection model, Lorenz discovered that tiny differences in initial conditions lead to completely different long-term behavior — the "butterfly effect." Three seemingly simple equations revealed the essential feature of chaos: the long-term unpredictability of deterministic systems.
|
|
77
|
-
|
|
78
|
-
**Modeling insight**: Chaos theory profoundly changed the philosophy of modeling — even if a model is perfectly correct, long-term prediction may be fundamentally impossible. Modelers must distinguish between "predictable timescales" and "unpredictable chaotic regimes."
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## Kalman Filtering (1960)
|
|
83
|
-
|
|
84
|
-
> x̂_{k|k} = x̂_{k|k-1} + K_k(z_k - H x̂_{k|k-1})
|
|
85
|
-
|
|
86
|
-
The Kalman filter is a recursive estimation method based on state-space models: it uses the system dynamics model to predict the state and then corrects the prediction with observational data. It unifies "model prediction" and "data updating" within a single mathematical framework and is a cornerstone of modern control theory and signal processing.
|
|
87
|
-
|
|
88
|
-
**Modeling insight**: Good modeling is not only about "building a model" but also about "making optimal estimates based on the model." The Kalman filter demonstrates how models and data work together — the model provides the prior, the data provide the correction, and neither is dispensable.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Pólya's *How to Solve It* (1945)
|
|
93
|
-
|
|
94
|
-
> "The first step in mathematical modeling is understanding the problem, the second is devising a plan, the third is carrying out the plan, and the fourth is looking back."
|
|
95
|
-
|
|
96
|
-
Pólya's problem-solving framework is a precursor to modeling thinking: transforming an unfamiliar problem into a known mathematical problem.
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Akaike Information Criterion (1974)
|
|
101
|
-
|
|
102
|
-
> AIC = -2 ln(L_max) + 2k
|
|
103
|
-
|
|
104
|
-
In 1974, Akaike proposed AIC, formalizing the model selection problem for the first time: striking an optimal balance between goodness of fit (-2 ln L) and model complexity (2k), where k is the number of parameters and L_max is the maximum likelihood.
|
|
105
|
-
|
|
106
|
-
**Modeling insight**: AIC established a mathematical standard for the "principle of parsimony" — neither the most complex nor the simplest model is best; rather, the optimal trade-off lies in minimizing information loss while keeping parameters parsimonious. This is the quantitative version of Box's dictum that "some are useful."
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## Black-Scholes Model (1973)
|
|
111
|
-
|
|
112
|
-
> C = S N(d₁) - K e^{-rT} N(d₂)
|
|
113
|
-
> d₁ = [ln(S/K) + (r + σ²/2)T] / (σ√T)
|
|
114
|
-
> d₂ = d₁ - σ√T
|
|
115
|
-
|
|
116
|
-
Black, Scholes, and Merton developed a mathematical model for option pricing. Based on geometric Brownian motion dS = μS dt + σS dW and the no-arbitrage principle, they derived the partial differential equation ∂C/∂t + ½σ²S²∂²C/∂S² + rS∂C/∂S - rC = 0. This model is the most celebrated result in financial mathematics; Scholes and Merton were awarded the 1997 Nobel Prize in Economics for this work.
|
|
117
|
-
|
|
118
|
-
**Modeling insight**: The Black-Scholes model is the best illustration of Box's dictum — its assumptions (constant volatility, continuous trading, frictionless markets) are all "wrong" in reality, yet it provides the core framework for pricing and risk management, and is therefore "useful."
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## George Box's Famous Quote
|
|
123
|
-
|
|
124
|
-
> "All models are wrong, but some are useful."
|
|
125
|
-
|
|
126
|
-
**Modeling philosophy**:
|
|
127
|
-
- A model is not reality — it is necessarily a simplification of reality
|
|
128
|
-
- The value of a model lies not in its "truthfulness" but in its predictive and explanatory power
|
|
129
|
-
- Criteria for a good model: parsimonious, testable, predictive
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## General Principles of Modeling
|
|
134
|
-
|
|
135
|
-
1. **Start simple**: Begin with the simplest model, then incrementally add complexity (Lorenz revealed chaos with three equations; Lotka-Volterra explained oscillations with two)
|
|
136
|
-
2. **State assumptions explicitly**: Record and test every assumption (Black-Scholes assumptions, though wrong, are explicit — and so the model remains usable)
|
|
137
|
-
3. **Validate and falsify**: Test models with independent data, not just by fitting (AIC quantifies the risk of overfitting)
|
|
138
|
-
4. **Know the scope**: Every model has a domain of validity; beyond it, the model fails (Newtonian mechanics fails at high velocities and requires Einstein's correction)
|
|
139
|
-
5. **Iterate**: Modeling is a cyclical process, not a one-shot endeavor (Pólya's "looking back" step)
|
|
140
|
-
6. **Unify dimensions**: Use the Buckingham Pi theorem to cast models in dimensionless form, reducing parameters and revealing structure
|
|
141
|
-
7. **Synergize models and data**: The Kalman filter demonstrates how model prediction and data correction work in a feedback loop
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
## Timeline of Mathematical Modeling
|
|
146
|
-
|
|
147
|
-
| Year | Achievement | Field |
|
|
148
|
-
|------|-------------|-------|
|
|
149
|
-
| 1687 | Newton *Principia* | Mechanics |
|
|
150
|
-
| 1822 | Fourier heat equation | Heat diffusion |
|
|
151
|
-
| 1865 | Maxwell's equations | Electromagnetism |
|
|
152
|
-
| 1914 | Buckingham Pi theorem | Dimensional analysis |
|
|
153
|
-
| 1925-26 | Lotka-Volterra | Population dynamics |
|
|
154
|
-
| 1927 | Kermack-McKendrick SIR | Epidemiology |
|
|
155
|
-
| 1945 | Pólya *How to Solve It* | Methodology |
|
|
156
|
-
| 1952 | Turing reaction-diffusion | Morphogenesis |
|
|
157
|
-
| 1960 | Kalman filter | Estimation & control |
|
|
158
|
-
| 1963 | Lorenz system | Chaos theory |
|
|
159
|
-
| 1973 | Black-Scholes | Finance |
|
|
160
|
-
| 1974 | Akaike AIC | Model selection |
|
|
161
|
-
|
|
162
|
-
This timeline reveals a central pattern: great modeling achievements often transcend disciplinary boundaries. Newton unified the heavens and the earth, Maxwell unified electricity and magnetism, Turing unified chemistry and biology — the power of mathematical models lies precisely in their cross-domain universality.
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# 数学出处与经典文献 / Mathematical Sources and Classic Texts
|
|
2
|
-
|
|
3
|
-
## Newton《自然哲学的数学原理》/ *Principia Mathematica* (1687)
|
|
4
|
-
|
|
5
|
-
> "自然界中的同一效应必须尽可能归因于同一原因。"
|
|
6
|
-
> "The same effects of nature must always be assigned to the same causes."
|
|
7
|
-
|
|
8
|
-
**数学建模史上最重要的成就**:Newton 将天体运动与地面运动统一在同一数学框架之下——万有引力定律 F = GMm/r² 与三大运动定律。这是人类首次用系统的数学模型精确描述物理世界,标志着科学建模的诞生。《原理》确立了"数学模型→物理预测→实验验证"的方法论范式,至今仍是所有建模工作的根基。
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Fourier 热传导方程 / Fourier's Heat Equation (1822)
|
|
13
|
-
|
|
14
|
-
> ∂u/∂t = κ ∇²u
|
|
15
|
-
|
|
16
|
-
Fourier 在《热的解析理论》中提出了热扩散的数学模型,并为此发明了 Fourier 分析——将任意函数分解为三角级数的方法。这一建模成就具有双重意义:既给出了热传导的精确数学描述,又催生了整个调和分析领域。Fourier 变换至今是信号处理、量子力学、图像压缩等领域的核心工具。
|
|
17
|
-
|
|
18
|
-
**建模启示**:解决一个建模问题所发明的新数学,往往比原模型本身更具深远影响。
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Maxwell 方程组 / Maxwell's Equations (1865)
|
|
23
|
-
|
|
24
|
-
> ∇·E = ρ/ε₀, ∇×E = -∂B/∂t
|
|
25
|
-
> ∇·B = 0, ∇×B = μ₀J + μ₀ε₀∂E/∂t
|
|
26
|
-
|
|
27
|
-
Maxwell 将电学与磁学统一为四个偏微分方程,从数学模型中预言了电磁波的存在——此预言后被 Hertz 实验证实。这是建模史上最辉煌的范例之一:仅凭数学推演便发现了全新的物理现象。方程还隐含光速 c = 1/√(μ₀ε₀),将光学纳入电磁理论,堪称统一建模的巅峰。
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Lotka-Volterra 捕食者-猎物模型 (1925-1926)
|
|
32
|
-
|
|
33
|
-
经典的种群动力学模型:
|
|
34
|
-
|
|
35
|
-
> dx/dt = αx - βxy (猎物增长 - 被捕食)
|
|
36
|
-
> dy/dt = δxy - γy (捕食者增长 - 自然死亡)
|
|
37
|
-
|
|
38
|
-
**建模启示**:通过两个简单的微分方程,成功解释了自然界中捕食者和猎物种群的周期性振荡现象。这是"好模型"的典范——简单但有用。
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Kermack-McKendrick SIR 传染病模型 (1927)
|
|
43
|
-
|
|
44
|
-
> dS/dt = -βSI (易感者减少)
|
|
45
|
-
> dI/dt = βSI - γI (感染者变化)
|
|
46
|
-
> dR/dt = γI (康复者增加)
|
|
47
|
-
|
|
48
|
-
**建模启示**:基本再生数 R₀ = β/γ 决定了疫情是否会爆发。Kermack 与 McKendrick 于 1927 年在论文 "A Contribution to the Mathematical Theory of Epidemics" 中首次提出此模型,奠定了传染病数学建模的理论基础。这个简单的模型在新冠疫情期间被广泛使用,证明了经典模型的持久价值。
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Buckingham Pi 定理 / Buckingham Pi Theorem (1914)
|
|
53
|
-
|
|
54
|
-
> 若物理关系涉及 n 个变量、含 k 个独立量纲,则该关系可简化为 (n-k) 个无量纲 Π 组之间的关系。
|
|
55
|
-
|
|
56
|
-
**建模启示**:Buckingham Pi 定理将量纲分析形式化,是建模中极其重要的简化工具。它告诉我们:任何物理模型都可化为无量纲形式,从而减少参数个数、揭示本质结构。例如,流体力学中雷诺数 Re = ρvL/μ 就是一个 Π 量,它统一了无数看似不同的流动情形。
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Turing 反应-扩散模型 / Turing's Reaction-Diffusion Model (1952)
|
|
61
|
-
|
|
62
|
-
> ∂u/∂t = D_u ∇²u + f(u,v)
|
|
63
|
-
> ∂v/∂t = D_v ∇²v + g(u,v)
|
|
64
|
-
|
|
65
|
-
Turing 在论文 "The Chemical Basis of Morphogenesis" 中证明:两种扩散速率不同的化学物质相互作用,可在均匀状态下产生稳定的空间图案——斑纹、条纹、螺旋等。这是形态发生的数学模型,解释了从豹斑到海贝壳花纹的广泛现象。
|
|
66
|
-
|
|
67
|
-
**建模启示**:数学模型可以解释"有序如何从无序中涌现"——无需预设图案,纯由方程动力学自发产生。Turing 由此开创了模式形成理论。
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Lorenz 系统 / Lorenz System (1963)
|
|
72
|
-
|
|
73
|
-
> dx/dt = σ(y - x)
|
|
74
|
-
> dy/dt = x(ρ - y) - xz
|
|
75
|
-
> dz/dt = xy - βz
|
|
76
|
-
|
|
77
|
-
Lorenz 在数值模拟大气对流模型时发现:初始条件的微小差异会导致完全不同的长期行为——即"蝴蝶效应"。三个看似简单的方程揭示了混沌的本质特征:确定性系统的长期不可预测性。
|
|
78
|
-
|
|
79
|
-
**建模启示**:混沌理论深刻改变了建模哲学——即便模型完全正确,长期预测也可能本质不可能。建模者必须区分"可预测的时间尺度"与"不可预测的混沌区域"。
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Kalman 滤波 / Kalman Filtering (1960)
|
|
84
|
-
|
|
85
|
-
> x̂_{k|k} = x̂_{k|k-1} + K_k(z_k - H x̂_{k|k-1})
|
|
86
|
-
|
|
87
|
-
Kalman 滤波是基于状态空间模型的递推估计方法:利用系统动力学模型预测状态,再用观测数据修正预测。它将"模型预测"与"数据更新"统一在一个数学框架中,是现代控制论与信号处理的基石。
|
|
88
|
-
|
|
89
|
-
**建模启示**:好的建模不仅是"建立模型",还包括"基于模型做最优估计"。Kalman 滤波展示了模型与数据如何协同工作——模型提供先验,数据提供校正,二者缺一不可。
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Pólya《怎样解题》/ *How to Solve It* (1945)
|
|
94
|
-
|
|
95
|
-
> "数学建模的第一步是理解问题,第二步是制定计划,第三步是执行计划,第四步是回顾。"
|
|
96
|
-
> "The first step in mathematical modeling is understanding the problem, the second is devising a plan, the third is carrying out the plan, and the fourth is looking back."
|
|
97
|
-
|
|
98
|
-
Pólya 的解题框架是建模思想的前身:将未知问题转化为已知的数学问题。
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Akaike 信息准则 / Akaike Information Criterion (1974)
|
|
103
|
-
|
|
104
|
-
> AIC = -2 ln(L_max) + 2k
|
|
105
|
-
|
|
106
|
-
Akaike 在 1974 年提出 AIC,首次将模型选择问题形式化:在拟合优度 (-2 ln L) 与模型复杂度 (2k) 之间寻求最优平衡。k 为参数个数,L_max 为最大似然。
|
|
107
|
-
|
|
108
|
-
**建模启示**:AIC 确立了"简约性原则"的数学标准——不是越复杂越好,也不是越简单越好,而是在信息损失最小化与参数简约化之间取最优折中。这是 Box 名言"有些是有用的"的量化版本。
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Black-Scholes 模型 / Black-Scholes Model (1973)
|
|
113
|
-
|
|
114
|
-
> C = S N(d₁) - K e^{-rT} N(d₂)
|
|
115
|
-
> d₁ = [ln(S/K) + (r + σ²/2)T] / (σ√T)
|
|
116
|
-
> d₂ = d₁ - σ√T
|
|
117
|
-
|
|
118
|
-
Black、Scholes 与 Merton 建立了期权定价的数学模型,基于几何布朗运动 dS = μS dt + σS dW 与无套利原理推导出偏微分方程 ∂C/∂t + ½σ²S²∂²C/∂S² + rS∂C/∂S - rC = 0。此模型是金融数学最著名的成果,Scholes 与 Merton 因此获 1997 年诺贝尔经济学奖。
|
|
119
|
-
|
|
120
|
-
**建模启示**:Black-Scholes 是 Box 名言的最佳注脚——模型假设(常数波动率、连续交易、无摩擦市场)在现实中都是"错的",但它提供了定价框架与风险管理的核心工具,因而是"有用的"。
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## George Box 的名言 / George Box's Famous Quote
|
|
125
|
-
|
|
126
|
-
> "All models are wrong, but some are useful."
|
|
127
|
-
> "所有模型都是错的,但有些是有用的。"
|
|
128
|
-
|
|
129
|
-
**建模哲学**:
|
|
130
|
-
- 模型不是现实——它必然是对现实的简化
|
|
131
|
-
- 模型的价值不在于"真实性",而在于其预测和解释能力
|
|
132
|
-
- 好模型的标准:简洁(parsimonious)、可检验(testable)、有预测力(predictive)
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## 建模的一般原则
|
|
137
|
-
|
|
138
|
-
1. **从简单开始**:先用最简单的模型,然后逐步增加复杂度(Lorenz 用三方程揭示混沌,Lotka-Volterra 用两方程解释振荡)
|
|
139
|
-
2. **明确假设**:每个假设都要记录和检验(Black-Scholes 的假设虽错但明确,因此仍可使用)
|
|
140
|
-
3. **验证与证伪**:用独立数据检验模型,而不仅是拟合数据(AIC 量化了过拟合的风险)
|
|
141
|
-
4. **适用范围**:每个模型都有其适用范围,超出范围即失效(Newton 力学在高速下失效,需 Einstein 修正)
|
|
142
|
-
5. **迭代改进**:建模是一个循环过程,不是一次性的(Pólya 的"回顾"步骤)
|
|
143
|
-
6. **量纲统一**:用 Buckingham Pi 定理将模型化为无量纲形式,减少参数、揭示结构
|
|
144
|
-
7. **模型与数据协同**:Kalman 滤波展示了模型预测与数据校正如何循环工作
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## 建模史的时间线 / Timeline of Mathematical Modeling
|
|
149
|
-
|
|
150
|
-
| 年份 | 成就 | 领域 |
|
|
151
|
-
|------|------|------|
|
|
152
|
-
| 1687 | Newton *Principia* | 力学 / Mechanics |
|
|
153
|
-
| 1822 | Fourier 热方程 | 热传导 / Heat diffusion |
|
|
154
|
-
| 1865 | Maxwell 方程组 | 电磁学 / Electromagnetism |
|
|
155
|
-
| 1914 | Buckingham Pi 定理 | 量纲分析 / Dimensional analysis |
|
|
156
|
-
| 1925-26 | Lotka-Volterra | 种群动力学 / Population dynamics |
|
|
157
|
-
| 1927 | Kermack-McKendrick SIR | 传染病 / Epidemiology |
|
|
158
|
-
| 1945 | Pólya *How to Solve It* | 方法论 / Methodology |
|
|
159
|
-
| 1952 | Turing 反应-扩散 | 形态发生 / Morphogenesis |
|
|
160
|
-
| 1960 | Kalman 滤波 | 估计与控制 / Estimation & control |
|
|
161
|
-
| 1963 | Lorenz 系统 | 混沌 / Chaos theory |
|
|
162
|
-
| 1973 | Black-Scholes | 金融 / Finance |
|
|
163
|
-
| 1974 | Akaike AIC | 模型选择 / Model selection |
|
|
164
|
-
|
|
165
|
-
这条时间线揭示了一个核心规律:伟大的建模成就往往跨越学科边界。Newton 统一了天与地,Maxwell 统一了电与磁,Turing 统一了化学与生物学——数学模型的力量恰恰在于它的跨领域普适性。
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: optimization
|
|
3
|
-
description: |
|
|
4
|
-
Trigger when a problem involves resource allocation, trade-offs, maximizing/minimizing objectives, decisions under constraints; or needs convexity analysis, Lagrangian/KKT methods, duality structure; or choosing optimization methods for algorithm/operator/training design.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Optimization
|
|
8
|
-
|
|
9
|
-
> "Under the most general constraints, find extrema of the objective -- convexity determines difficulty, KKT gives necessity, duality reveals structure."
|
|
10
|
-
>
|
|
11
|
-
> -- Optimization Theory & Operations Research
|
|
12
|
-
|
|
13
|
-
## Core Principle
|
|
14
|
-
|
|
15
|
-
**Any decision problem can be formulated as an optimization problem: maximizing (or minimizing) an objective subject to constraints. The essence of optimization is not the pursuit of "the best" in the abstract, but "the best among the feasible."**
|
|
16
|
-
|
|
17
|
-
The three core elements of optimization: **Objective**, **Constraints**, **Feasible set**.
|
|
18
|
-
|
|
19
|
-
> **Mathematical Formalization**
|
|
20
|
-
>
|
|
21
|
-
> General optimization problem: $\min_{x \in \mathbb{R}^n} f(x) \quad \text{s.t.} \quad g_i(x) \leq 0,\; i=1,\dots,m; \quad h_j(x) = 0,\; j=1,\dots,p$
|
|
22
|
-
>
|
|
23
|
-
> Lagrangian: $L(x, \lambda, \mu) = f(x) + \sum_i \lambda_i g_i(x) + \sum_j \mu_j h_j(x)$
|
|
24
|
-
>
|
|
25
|
-
> KKT conditions (essential necessary conditions, under Slater-type constraint qualifications): (1) Stationarity $\nabla_x L = 0$; (2) Primal feasibility $g_i \le 0, h_j = 0$; (3) Dual feasibility $\lambda_i \ge 0$; (4) Complementary slackness $\lambda_i g_i = 0$.
|
|
26
|
-
>
|
|
27
|
-
> Convexity: If $f$ and each $g_i$ are convex and each $h_j$ is linear, the problem is convex; in this case **KKT is sufficient**, and local optimality implies global optimality.
|
|
28
|
-
|
|
29
|
-
## GPU-Friendliness (Cross-Cutting Check)
|
|
30
|
-
|
|
31
|
-
When optimization is used for **algorithm/operator/training design**, the solution method itself must pass the eight-dimensional gate in `../../references/gpu-friendly-math.md`:
|
|
32
|
-
|
|
33
|
-
- **First-order methods (SGD/Adam)**: GEMM-friendly, parallelizable, viable in low precision; pay attention to optimizer state precision and distributed communication overhead.
|
|
34
|
-
- **Second-order / Newton methods**: Hessian inversion $O(n^3)$, memory explosion -- the classic "beautiful but incomputable" case -- adapt to **K-FAC / low-rank / diagonal approximations** (see `../../references/books/optimization-ml.md`, `matrix-analysis.md`).
|
|
35
|
-
- **Constraint projection**: Does the projection admit a closed form and is it tensorizable? Iterative projection requires caution regarding serial dependencies.
|
|
36
|
-
- **Distribution**: Can computation and communication overlap? Is gradient compression needed?
|
|
37
|
-
|
|
38
|
-
Eight-dimensional minimum assessment (formal terms): **Tensorization** -- whether objectives / constraints / gradients can be batched; **GEMM-mappability** -- whether the primary computation is matrix multiplication, HVP, or small K-FAC matrices; **Complexity** -- order of first-order / second-order / combinatorial solvers; **Memory & KV-Cache** -- optimizer states, Hessian storage, activation retention; **Low-precision stability** -- condition numbers, damping, loss scaling; **Parallelism & communication** -- gradient synchronization and communication overlap; **Sparse structure** -- whether preconditioners / constraints are block-structured; **Operator fusion** -- whether updates, clipping, and regularization can be fused.
|
|
39
|
-
|
|
40
|
-
> Cross-reference `../../references/books/optimization-ml.md` (Chong/Lu/Żak) and `../../references/books/matrix-analysis.md`.
|
|
41
|
-
|
|
42
|
-
## When NOT to Use
|
|
43
|
-
|
|
44
|
-
- **No clear evaluation criterion** (one does not know what "good" means) -- define the objective before optimizing.
|
|
45
|
-
- **Purely execution-oriented tasks** (e.g., formatting code) -- there is no optimization space.
|
|
46
|
-
- **The user has already decided on a plan** -- optimization is already complete.
|
|
47
|
-
- **The problem is essentially qualitative judgment rather than quantitative extremum** -- model first, then optimize.
|
|
48
|
-
|
|
49
|
-
## When to Use
|
|
50
|
-
|
|
51
|
-
- When one needs to determine whether a problem is convex in order to assess solution difficulty.
|
|
52
|
-
- Choosing optimization methods for algorithm/operator/training design and evaluating their GPU viability.
|
|
53
|
-
- Making rational decisions with quantifiable objectives under constraints.
|
|
54
|
-
- Systematic optimization of experimental design, resource allocation, and hyperparameter / architecture search.
|
|
55
|
-
- When one is uncertain whether the current strategy is optimal and wishes to perform a systematic analysis (convexity, duality, sensitivity).
|
|
56
|
-
|
|
57
|
-
## Method
|
|
58
|
-
|
|
59
|
-
### Step 1: Define the Objective
|
|
60
|
-
Clarify what is to be maximized / minimized. Key questions: Single-objective or multi-objective? Is it quantifiable (otherwise, find proxy variables)? Static or dynamic? **Is $f$ convex** (convex implies local = global; non-convex requires vigilance against local extrema)? A wrong objective leads further astray the further one proceeds.
|
|
61
|
-
|
|
62
|
-
### Step 2: List the Constraints
|
|
63
|
-
Distinguish **hard constraints** (physical / budget / deadline) from **soft constraints** (preferences / quality floors); mathematically classify: inequality $g_i(x)\le 0$ (defines the boundary of the feasible set), equality $h_j(x)=0$ (reduces dimensionality), linear (feasible set is a convex polyhedron) vs. nonlinear (may be non-convex).
|
|
64
|
-
|
|
65
|
-
### Step 3: Classify the Problem Type
|
|
66
|
-
|
|
67
|
-
| Type | Objective | Constraints | Key Property | Typical Method |
|
|
68
|
-
|------|-----------|-------------|--------------|----------------|
|
|
69
|
-
| LP (Linear Programming) | Linear | Linear inequalities | Optimum at a vertex | Simplex method |
|
|
70
|
-
| QP (Quadratic Programming) | Quadratic | Linear | Positive-definite QP is convex | Interior-point method |
|
|
71
|
-
| Convex optimization | Convex | Convex inequalities + linear equalities | Local = global | Gradient descent, interior-point methods |
|
|
72
|
-
| Non-convex optimization | Non-convex | Arbitrary | Multiple local extrema | Global search, simulated annealing |
|
|
73
|
-
| Combinatorial optimization | Discrete domain | Arbitrary | Frequently NP-hard | Branch-and-bound, heuristics |
|
|
74
|
-
| Stochastic optimization | Contains random terms | May include stochastic constraints | Expected optimum vs. stochastic feasibility | SAA, robust optimization |
|
|
75
|
-
|
|
76
|
-
### Step 4: Find the Optimal Solution
|
|
77
|
-
- **LP/QP/Convex**: Exploit convexity; gradient-based or interior-point methods guarantee convergence to the global optimum.
|
|
78
|
-
- **Non-convex**: Multi-start strategies, global search, or relaxation to convex approximations.
|
|
79
|
-
- **Combinatorial**: Exact solutions are often NP-hard -- branch-and-bound for small scale, heuristics / approximations for large scale.
|
|
80
|
-
- **Stochastic**: Sample Average Approximation (SAA) converts to a deterministic approximation.
|
|
81
|
-
- **Insufficient information**: A satisficing solution suffices.
|
|
82
|
-
|
|
83
|
-
### Step 5: Sensitivity Analysis
|
|
84
|
-
The Lagrange multiplier $\lambda_i^*$ is the **shadow price** of the $i$-th constraint -- relaxing the constraint by one unit improves the objective by approximately $\lambda_i^*$. Complementary slackness: $\lambda_i^*=0$ indicates an inactive constraint (no effect on the optimal solution); $\lambda_i^*>0$ indicates an active constraint (the optimal solution lies precisely at its boundary). Focus on: how the optimal solution changes under small perturbations of constraints / objective, and which constraints are active.
|
|
85
|
-
|
|
86
|
-
### Step 6: Multi-Objective & Pareto
|
|
87
|
-
Multi-objective problems $f_1,\dots,f_k$ generally have no single optimal solution. Pareto optimality: no feasible solution exists that improves all objectives simultaneously. Methods: **Weighted sum** $\min\sum w_i f_i$ (different weights trace different points on the Pareto front); **$\epsilon$-constraint method** $\min f_1$ s.t. $f_i\le\epsilon_i$ (sweep $\epsilon_i$ to cover the front).
|
|
88
|
-
|
|
89
|
-
### Step 7: Monitor Constraint Changes
|
|
90
|
-
The optimal solution depends on the constraints -- when constraints change, re-optimization is required. Changes in active constraints have the greatest impact (high shadow prices); small changes in inactive constraints typically do not affect the optimal solution.
|
|
91
|
-
|
|
92
|
-
## Common Errors
|
|
93
|
-
|
|
94
|
-
| Error | Critique | Correct Approach |
|
|
95
|
-
|-------|----------|------------------|
|
|
96
|
-
| Optimizing without a clear objective | Direction is undefined | Precisely define the objective first |
|
|
97
|
-
| Ignoring implicit constraints | The "optimal solution" is actually infeasible | Exhaustively verify all constraints |
|
|
98
|
-
| Getting trapped in local optima | Greedy methods on non-convex problems do not guarantee global optimality | Verify convexity; use multi-start / global methods for non-convex problems |
|
|
99
|
-
| Treating the optimum as unique | The optimal solution may not be unique | Check for the existence of multiple equivalent optima |
|
|
100
|
-
| Using single-objective methods for multi-objective problems | Different objectives require trade-offs | Employ Pareto analysis |
|
|
101
|
-
| Failing to verify convexity | Applying convex methods to non-convex problems | Determine convexity before selecting a method |
|
|
102
|
-
| Ignoring duality theory | The dual problem may be easier to solve | Construct the dual and exploit strong duality |
|
|
103
|
-
| Confusing feasibility with optimality | Feasible does not imply optimal | Verify feasibility first, then verify optimality |
|
|
104
|
-
| Ignoring computational / GPU complexity | Second-order methods / combinatorial optimization may be incomputable | Assess complexity, pass the GPU eight-dimensional gate, approximate when necessary |
|
|
105
|
-
| Forgetting to re-optimize | Failing to update when constraints change | Periodically check for constraint changes |
|
|
106
|
-
|
|
107
|
-
## Operating Procedure
|
|
108
|
-
|
|
109
|
-
When this skill is triggered, the output must include:
|
|
110
|
-
|
|
111
|
-
1. **Objective function**: `[Objective]: [Description]` + `[Convexity]: [Convex / Non-convex / Unknown]`
|
|
112
|
-
2. **Constraint list**: Each labeled `[Hard / Soft]` and `[Inequality / Equality]` `[Linear / Nonlinear]`
|
|
113
|
-
3. **Problem type classification**: `[Type]: [LP / QP / Convex / Non-convex / Combinatorial / Stochastic]`
|
|
114
|
-
4. **Feasible set analysis**: Which options are feasible? Which constraints are active?
|
|
115
|
-
5. **Optimal / satisficing solution**: `[Strategy]: [Gradient method / Interior-point / Global search / Satisficing / Pareto]`
|
|
116
|
-
6. **Sensitivity analysis**: Shadow prices of key constraints? How do conclusions change under X% variation?
|
|
117
|
-
7. **GPU viability** (if used for algorithm/operator/training): Does the solution method pass the eight-dimensional gate? Label as friendly / retrofittable / unfriendly, with adaptation recommendations.
|
|
118
|
-
8. **Action recommendations**: Explicitly state "Next, I will..."
|
|
119
|
-
|
|
120
|
-
**Output must not consist of analysis alone without conclusions.**
|
|
121
|
-
|
|
122
|
-
## Relations to Other Skills
|
|
123
|
-
|
|
124
|
-
- **Modeling**: Optimization requires prior modeling -- defining objectives and constraints is itself an act of modeling.
|
|
125
|
-
- **Probability and statistics**: Optimization under uncertainty requires stochastic / robust optimization.
|
|
126
|
-
- **Transformation**: Transforming to the dual problem often makes optimization easier; duality is the most profound transformation in optimization.
|
|
127
|
-
- **Game-theoretic thinking**: Multiple decision-makers simultaneously optimizing constitutes a game; the Nash equilibrium is the stable point of multi-player optimization.
|
|
128
|
-
- **Algorithmic thinking**: Solution methods depend on algorithm design -- convex optimization uses gradient methods, combinatorial optimization requires branch-and-bound / heuristics.
|
|
129
|
-
- **Modern mathematics activation**: `../../references/books/optimization-ml.md` (GPU-friendly optimizers, feasibility of second-order methods), `matrix-analysis.md` (condition numbers, low-rank, preconditioning).
|