{
  "$schema": "../../../schemas/mko-v0.4.schema.json",
  "schema_version": "mko-v0.4",
  "id": "mko-law-of-total-variance",
  "semantic_family_id": "sf-law-of-total-variance",
  "type": "theorem",
  "version": "0.10.0",
  "language": "zh-Hant",
  "titles": {
    "zh-Hant": "全變異數公式"
  },
  "summary": {
    "zh-Hant": "同一有限law與完整partition生成的G下，總變異數等於cell內變異數期望加cell均值變異數。"
  },
  "statement": {
    "zh-Hant": "Var(X)=E[Var(X|G)]+Var(E[X|G])。partition cells兩兩不交、非空且union為全部outcomes；zero-mass cell仍是含零質量outcomes的非空事件。同一cell conditional mean與variance使用同一law；positive-mass cell才可除法。zero-mass cell條件值只a.s.決定，外層加權貢獻為0。within與between不可交換或漏項，不要求partition events independent。"
  },
  "formula": {
    "tex": "V(X)=E(V(X\\mid G))+V(E(X\\mid G))",
    "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mrow><mi>V</mi><mo>(</mo><mi>X</mi><mo>)</mo></mrow><mo>=</mo><mrow><mrow><mi>E</mi><mo>(</mo><mrow><mi>V</mi><mo>(</mo><mrow><mi>X</mi><mo>|</mo><mi>G</mi></mrow><mo>)</mo></mrow><mo>)</mo></mrow><mo>+</mo><mrow><mi>V</mi><mo>(</mo><mrow><mi>E</mi><mo>(</mo><mrow><mi>X</mi><mo>|</mo><mi>G</mi></mrow><mo>)</mo></mrow><mo>)</mo></mrow></mrow></mrow></math>",
    "semantic_ast": {
      "type": "equation",
      "lhs": {
        "type": "function_call",
        "callee": {
          "type": "symbol",
          "name": "V",
          "glyph": "V"
        },
        "arguments": [
          {
            "type": "symbol",
            "name": "X",
            "glyph": "X"
          }
        ]
      },
      "rhs": {
        "type": "addition",
        "operands": [
          {
            "type": "function_call",
            "callee": {
              "type": "symbol",
              "name": "E",
              "glyph": "E"
            },
            "arguments": [
              {
                "type": "function_call",
                "callee": {
                  "type": "symbol",
                  "name": "V",
                  "glyph": "V"
                },
                "arguments": [
                  {
                    "type": "conditional",
                    "expression": {
                      "type": "symbol",
                      "name": "X",
                      "glyph": "X"
                    },
                    "condition": {
                      "type": "symbol",
                      "name": "G",
                      "glyph": "G"
                    }
                  }
                ]
              }
            ]
          },
          {
            "type": "function_call",
            "callee": {
              "type": "symbol",
              "name": "V",
              "glyph": "V"
            },
            "arguments": [
              {
                "type": "function_call",
                "callee": {
                  "type": "symbol",
                  "name": "E",
                  "glyph": "E"
                },
                "arguments": [
                  {
                    "type": "conditional",
                    "expression": {
                      "type": "symbol",
                      "name": "X",
                      "glyph": "X"
                    },
                    "condition": {
                      "type": "symbol",
                      "name": "G",
                      "glyph": "G"
                    }
                  }
                ]
              }
            ]
          }
        ]
      }
    },
    "compiler": {
      "id": "ocme-formula-core",
      "version": "0.4.0",
      "source_sha256": "2532a8787916d3f6a1b0e9a9e1f542c7f1a22a72aa96bbc205016d3d8c2a2c44"
    }
  },
  "assumptions": [
    {
      "id": "a1",
      "zh-Hant": "完整正規化有限law、exact values與由非空cells組成的完整disjoint partition。"
    },
    {
      "id": "a2",
      "zh-Hant": "G由該partition生成；zero-mass cells不做conditional division。"
    }
  ],
  "symbols": [
    {
      "token": "V",
      "role": "variance_operator",
      "role_zh": "變異數算子",
      "scope": "representative_formula"
    },
    {
      "token": "X",
      "role": "finite_random_variable",
      "role_zh": "有限隨機變數",
      "scope": "representative_formula"
    },
    {
      "token": "E",
      "role": "expectation_operator",
      "role_zh": "期望算子",
      "scope": "representative_formula"
    },
    {
      "token": "G",
      "role": "partition_generated_sigma_algebra",
      "role_zh": "partition生成的sigma-algebra",
      "scope": "representative_formula"
    }
  ],
  "dependencies": [
    {
      "id": "mko-law-of-total-expectation",
      "title_zh": "全期望公式",
      "reason_zh": "tower identity。"
    },
    {
      "id": "mko-variance",
      "title_zh": "有限機率分布的變異數",
      "reason_zh": "global/cell variance。"
    },
    {
      "id": "mko-conditional-expectation",
      "title_zh": "有限模型的條件期望",
      "reason_zh": "cell means。"
    }
  ],
  "explanation": {
    "paragraphs_zh": [
      "partition cells非空；zero-mass指cell含有outcomes但其總機率為0。",
      "within term平均cell variances。",
      "between term計算cell means的variance，且zero-mass cell不影響兩個outer terms。"
    ],
    "common_misconception_zh": "以empty cell冒充zero-mass event、漏掉between term、交換兩項語義或除以0。"
  },
  "proofs": [],
  "computational_companions": [],
  "verification": {
    "computational_status": "not_evaluated_no_computational_claim",
    "warning_zh": "本輪限完整有限law；一般conditional variance需measure-theoretic證明。",
    "evidence_refs": [],
    "producers": [
      {
        "id": "lean-mathlib",
        "adapter": "formal_system",
        "config_path": "formal/lean/lakefile.toml",
        "status": "configured"
      }
    ]
  },
  "formalization": {
    "status": "not_formalized",
    "target_systems": [
      "Lean 4",
      "Mathlib"
    ],
    "next_obligation_zh": "加入bias-variance decomposition。"
  },
  "provenance": {
    "origin": "ocme_local_ai_materialization_candidate",
    "note_zh": "依 research/atlas-law-of-total-variance.md 整理；2026-10-14 脈衝 R04（使用者手動接續 2026-11-10 工作序列；實際日期仍為 2026-10-14），英文及 Lean 依使用者指示延後。",
    "content_license": "CC-BY-SA-4.0",
    "code_license": "MIT",
    "created_at": "2026-10-14"
  }
}
