{
  "schema_version": "ocme-derivation-reader-v1",
  "guide_id": "derivation-mko-law-of-total-variance-01",
  "mko_id": "mko-law-of-total-variance",
  "title": {
    "zh-Hant": "within與between的精確分解",
    "en": "Exact within-between variance decomposition"
  },
  "contract": {
    "schema_version": "ocme-derivation-guide-v0.1",
    "guide_id": "derivation-mko-law-of-total-variance-01",
    "source": {
      "mko_id": "mko-law-of-total-variance",
      "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
      "sha256": "603199e10801a37db817e6bb93a0c0e3caac715f1667385f7837bbca5fd374f3",
      "english_sha256": "ae67ca99bc2e4fe0a83cf4359affb5afe7aa7722c78181f9c5216e49d4a5fed7"
    },
    "mode": "worked_example",
    "audience_prerequisites": [
      "work"
    ],
    "goal": {
      "zh-Hant": "用含null塊的完整law分解variance。",
      "en": "Decompose variance in a complete law with a null block."
    },
    "givens": [
      {
        "id": "G1",
        "statement": {
          "zh-Hant": "Ω={a,b,c,d,e}，質量(1/8,3/8,1/4,1/4,0)，X=(0,2,4,4,99)；B1={a,b}，B2={c,d}，B0={e}，G=σ({B1,B2,B0})。",
          "en": "Omega={a,b,c,d,e} has masses(1/8,3/8,1/4,1/4,0), X=(0,2,4,4,99); B1={a,b}, B2={c,d}, B0={e}, and G is their generated sigma-algebra."
        }
      }
    ],
    "steps": [
      {
        "id": "S01",
        "uses": [
          "G1",
          "work"
        ],
        "before_tex": "B_1=\\{a,b\\},B_2=\\{c,d\\},B_0=\\{e\\}",
        "after_tex": "(P(B_1),P(B_2),P(B_0))=(1/2,1/2,0)",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "三塊非空互斥且窮盡，B0含零質量原子e。",
          "en": "The three nonempty blocks are disjoint and exhaustive; B0 contains null atom e."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "work"
          ],
          "explanation": {
            "zh-Hant": "空集合不能冒充這裡指定的null cell。",
            "en": "The empty set is not the specified null cell."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S02",
        "uses": [
          "G1",
          "S01",
          "work"
        ],
        "before_tex": "E[X]=2(3/8)+4(1/4+1/4)",
        "after_tex": "\\mu=11/4",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "先固定此law的全域中心。",
          "en": "Fix the global center under this law first."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S01",
            "work"
          ],
          "explanation": {
            "zh-Hant": "e的99值以零質量加權。",
            "en": "The value 99 at e is weighted by zero."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S03",
        "uses": [
          "G1",
          "S02",
          "work"
        ],
        "before_tex": "E[X^2]=4(3/8)+16(1/4+1/4)",
        "after_tex": "\\operatorname{Var}(X)=19/2-(11/4)^2=31/16",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "由完整二次矩獨立取得全域variance。",
          "en": "Obtain global variance independently from the complete second moment."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S02",
            "work"
          ],
          "explanation": {
            "zh-Hant": "mean平方為121/16，不是對mean再平方加權。",
            "en": "The squared mean is 121/16, not a new weighted moment."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S04",
        "uses": [
          "G1",
          "S03",
          "work"
        ],
        "before_tex": "P(a\\mid B_1)=1/4,\\ P(b\\mid B_1)=3/4",
        "after_tex": "m_1=3/2,\\quad v_1=(1/4)(3/2)^2+(3/4)(1/2)^2=3/4",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "第一塊先正規化，再以同一cell mean計算variance。",
          "en": "Normalize the first block, then use its own mean for its variance."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S03",
            "work"
          ],
          "explanation": {
            "zh-Hant": "若以全域11/4中心化，得到的不是cell variance。",
            "en": "Centering at global11/4 would not give the cell variance."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S05",
        "uses": [
          "G1",
          "S04",
          "work"
        ],
        "before_tex": "X|_{B_2}=4",
        "after_tex": "m_2=4,\\quad v_2=0",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "第二塊恆定，因此cell variance零。",
          "en": "The second block is constant, so its conditional variance is zero."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S04",
            "work"
          ],
          "explanation": {
            "zh-Hant": "B0的mean與variance保持版本選擇，不除零。",
            "en": "Null-block mean and variance remain version choices, with no division by zero."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S06",
        "uses": [
          "G1",
          "S05",
          "work"
        ],
        "before_tex": "E[\\operatorname{Var}(X\\mid G)]",
        "after_tex": "(1/2)(3/4)+(1/2)0=3/8",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "within term是cell variances的外層加權平均。",
          "en": "The within term is the outer weighted average of cell variances."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S05",
            "work"
          ],
          "explanation": {
            "zh-Hant": "此項不是cell means的variance。",
            "en": "This term is not the variance of the cell means."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S07",
        "uses": [
          "G1",
          "S06",
          "work"
        ],
        "before_tex": "\\operatorname{Var}(E[X\\mid G])",
        "after_tex": "\\tfrac12(3/2-11/4)^2+\\tfrac12(4-11/4)^2=25/16",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "between term以全域中心計算兩個cell means的variance。",
          "en": "The between term uses the global center for the variance of the two cell means."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S06",
            "work"
          ],
          "explanation": {
            "zh-Hant": "null版本乘零，不改between項。",
            "en": "The null version is weighted by zero and cannot change this term."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S08",
        "uses": [
          "G1",
          "S07",
          "work"
        ],
        "before_tex": "X-\\mu=(X-m_i)+(m_i-\\mu)\\quad\\text{on }B_i",
        "after_tex": "(X-\\mu)^2=(X-m_i)^2+2(X-m_i)(m_i-\\mu)+(m_i-\\mu)^2",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "逐cell展開完整平方，保留兩個純平方與cross term。",
          "en": "Expand the square on each cell, retaining both squares and the cross term."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S07",
            "work"
          ],
          "explanation": {
            "zh-Hant": "係數2不能漏掉，m_i在cell內是常數。",
            "en": "The coefficient 2 is required and m_i is constant within the cell."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S09",
        "uses": [
          "G1",
          "S08",
          "work"
        ],
        "before_tex": "E[X-m_i\\mid B_i]=m_i-m_i=0",
        "after_tex": "E[(X-\\mu)^2\\mid B_i]=v_i+(m_i-\\mu)^2",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "把cell常數m_i-μ提出，cross term為2(m_i-μ)乘零。",
          "en": "Factor out the cell constant m_i-mu; the cross term is 2(m_i-mu) times zero."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S08",
            "work"
          ],
          "explanation": {
            "zh-Hant": "只在正質量cell取條件商；null cell外層貢獻零。",
            "en": "Take conditional quotients only on positive-mass cells; null cells have zero outer weighted contribution."
          }
        },
        "leaf_basis": "work"
      },
      {
        "id": "S10",
        "uses": [
          "G1",
          "S09",
          "work"
        ],
        "before_tex": "\\sum_{i:P(B_i)>0}P(B_i)E[(X-\\mu)^2\\mid B_i]",
        "after_tex": "\\operatorname{Var}(X)=\\sum_iP(B_i)v_i+\\sum_iP(B_i)(m_i-\\mu)^2=3/8+25/16=31/16",
        "relation": "implies",
        "rule": "work",
        "conditions": [],
        "explanation": {
          "zh-Hant": "使用完整partition加權，第一和為within、第二和為between。",
          "en": "Weight over the complete partition; the first sum is within and the second between."
        },
        "reverse_audit": {
          "kind": "premise_audit",
          "required_ids": [
            "G1",
            "S09",
            "work"
          ],
          "explanation": {
            "zh-Hant": "兩項俱全並與直接31/16比對，沒有以獨立假設消cross term。",
            "en": "Both terms match the direct31/16; no independence assumption eliminated the cross term."
          }
        },
        "leaf_basis": "work"
      }
    ],
    "result": {
      "zh-Hant": "全域variance31/16=within3/8+between25/16。",
      "en": "Global variance 31/16 equals within3/8 plus between25/16."
    },
    "negative_controls": [
      {
        "claim": {
          "zh-Hant": "只需within3/8。",
          "en": "The within term3/8 is sufficient."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "cell means不同，between25/16不能漏。",
          "en": "Different cell means contribute the additional25/16."
        }
      },
      {
        "claim": {
          "zh-Hant": "B0可用空集合代替。",
          "en": "B0 can be replaced by the empty set."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "本模型B0={e}且carrier需完整partition。",
          "en": "Here B0={e}; the partition must cover the whole carrier."
        }
      },
      {
        "claim": {
          "zh-Hant": "within是cell means的variance。",
          "en": "Within means the variance of cell means."
        },
        "expected": "reject",
        "reason": {
          "zh-Hant": "那是between；within是加權cell variances。",
          "en": "That is between; within averages cell variances."
        }
      }
    ],
    "status": "candidate",
    "gaps": [],
    "verification": {
      "structure": "checked_local_script",
      "mathematics": "candidate_argument",
      "formalization": "not_formalized"
    },
    "rule_glossary": [
      {
        "id": "mko_definition",
        "kind": "cited",
        "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。",
          "en": "Var(X)=E[Var(X|G)]+Var(E[X|G]). Partition cells are pairwise disjoint, nonempty and cover every outcome; a zero-mass cell is still a nonempty event consisting of zero-mass outcomes. Cell means and variances use the same law, with division only on positive-mass cells. Null-cell conditional versions are determined only almost surely and their outer weighted contribution is 0. Neither term may be omitted or have its meaning exchanged. No independence of partition events is required."
        },
        "source": {
          "mko_id": "mko-law-of-total-variance",
          "sha256": "603199e10801a37db817e6bb93a0c0e3caac715f1667385f7837bbca5fd374f3",
          "commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f"
        }
      },
      {
        "id": "work",
        "kind": "prerequisite",
        "statement": {
          "zh-Hant": "有限全期望、variance中心二次矩、平方展開；每個正質量cell的E[X-m_i|B_i]=0。",
          "en": "Finite total expectation, centered second moments and square expansion; E[X-m_i|B_i]=0 on each positive-mass cell."
        }
      }
    ],
    "revision_log": [],
    "numeric_checks": [
      {
        "id": "N01",
        "lhs": "19/2-(11/4)**2",
        "rhs": "31/16"
      },
      {
        "id": "N02",
        "lhs": "(1/4)*(3/2)**2+(3/4)*(1/2)**2",
        "rhs": "3/4"
      },
      {
        "id": "N03",
        "lhs": "3/8+25/16",
        "rhs": "31/16"
      }
    ]
  },
  "presentation": {
    "md_scope": {
      "zh-Hant": "非空partition cells；所有條件值只在正質量cell做除法。",
      "en": "Nonempty partition cells; divide only on positive-mass cells."
    },
    "md_symbols": [
      [
        "m_i,v_i",
        "cell mean與variance",
        "cell mean and variance"
      ],
      [
        "μ",
        "全域mean",
        "global mean"
      ]
    ],
    "md_error_controls": [
      {
        "title": "同cell中心 / Cell center",
        "zh": "B1使用3/2，不用11/4計cell variance。",
        "en": "Use3/2, not 11/4, for the B1 variance."
      },
      {
        "title": "cross term / Cross term",
        "zh": "以cell-centered誤差條件mean零消去，而非假設獨立。",
        "en": "Eliminate it using zero conditional mean, not an independence assumption."
      }
    ],
    "md_open_items": []
  },
  "revision": {
    "id": "ocme-new142-reader-adoption-20261021",
    "collection": "coverage-20261021",
    "source_commit": "b1b2f1dcf8c50d67a93fe52d95f8eef7b3abba9f",
    "adopted_source_sha256": "668efe3c54e9427c01450e0e91f89eb655c95d12eb112772605e6dee4a187fe5",
    "original_source_sha256": "d743eb39e9043e0455cec097334446bb62dc2ae0f693eb96b73f9a4a55b92452",
    "owner_adopted": true,
    "bilingual_sync": "complete_source_bound",
    "formal_Lean": "NOT_RUN",
    "reader_review": "142_of_142_source_bound",
    "wording_review": "original_Lead_decisions_resolved",
    "glossary_reader_paraphrases": [
      "mko_definition"
    ],
    "independent_AI_concurrence": "SCOPED_LEAD_AND_BILINGUAL_CONTEXT_REVIEW",
    "issue_ids": [
      "BR142-S163",
      "BR142-S162",
      "BR142-S157",
      "BR142-S158",
      "BR142-S159",
      "BR142-S160",
      "BR142-S161",
      "BR142-P054"
    ],
    "parent_manifest_sha256": "d29f4cae8229ebd24f60d496cb1d3cd4ad8c0a4dca9d44daab0c3245c544283a",
    "scope": "Owner-adopted reader revision. Lead and bilingual review concern the recorded text and premises; no new universal or Lean proof, canonical promotion or historical-label rewrite."
  }
}
