26 / 90

第 26 日:確率変数・期待値・標本抽出と最尤推定

離散確率変数と分布を定義し、期待値と分散を手計算し、シード固定の標本で経験分布を作り、ゼロカウントの失敗を含めて最尤推定を導出する。

数学とアルゴリズム基礎 480 分(8 時間の集中学習)
01 120 分

確率変数と確率分布

予測と観測の証跡を記録した後にのみ補助を利用できます。

前提条件

Day 25(確率の基礎)を完了すること。行き詰まった場合は記載の回復リンク(Day 21)を使う。

学習目標

離散確率変数を結果から数への関数として定義し、確率分布表を検証し、トークン上のカテゴリ分布につなげる。

手順

確率変数 $X$ は標本空間の各結果を数へ写す関数で、その分布は $\sum_x P(X=x)=1$ を満たす $P(X=x)$ の一覧。公平なサイコロなら $X$ は $\{1,\dots,6\}$ 上の一様分布。必須作業:サイコロの $E[X]$ を計算し、値 $\{0,1,2,3\}$ 上のトークン型分布 $p=[0.5,0.25,0.125,0.125]$ を検証する。

演習と予測記録

(a) 公平なサイコロの $E[X]$ を求め、非整数の期待値が結果と矛盾しない理由を説明せよ。(b) $\{0,1,2,3\}$ 上の $p=[0.5,0.25,0.125,0.125]$ で $\sum p = 1$ を確かめ $P(X\ge 2)$ を求めよ。(c) $p$ を 4 つのトークン型上のカテゴリ分布と見ると、最もありそうなトークンはどれか?

独立習得基準

正規化 $\sum p = 1$ を検証し、$P(X\ge2)=0.25$ を計算し、期待値が単一の結果とは別の平均であると説明できること。

公式ソースリソースと権利証跡

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

著者・提供機関: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapter 4: Discrete Random Variables (probability distribution functions)

検証バージョンと日付: 2e web edition (Verified: 2026-10-30)

選定理由:

Open textbook treatment of discrete random variables and distribution tables.

ソース前提知識:

High-school algebra; Day 25 probability foundations

安全フォールバック(オフライン回復性):

All required definitions, tables, and worked answers are reproduced locally in this lesson.

比較対象候補リソースと選定評価 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking Stanford copyright; public course notes No text extraction or redistribution permitted

CS229 Review of Probability Theory

著者・提供機関: Stanford CS229 course staff (Arian Maleki, Tom Do) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 2.4-2.5: Random variables, distributions, expectation

検証バージョンと日付: 2020 public course notes (Verified: 2026-10-30)

選定理由:

ML-oriented definition of random variables bridging to categorical token distributions.

ソース前提知識:

Multivariate calculus notation exposure

安全フォールバック(オフライン回復性):

Self-contained definitions and derivations in activity instructions and offline guide.

比較対象候補リソースと選定評価 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Co-selected: provides the gentler beginner narrative; CS229 provides the ML-oriented notation bridge.

MIT OCW 18.05 Introduction to Probability and Statistics ↗ compared_alternative [CC BY-NC-SA 4.0]

Strong full-course treatment with noncommercial/share-alike terms; heavier than the compact CS229 reference for this three-day block.

02 120 分

期待値・分散と分布表の計算練習

独立習得チェック(AI 補助なし)。

前提条件

前のアクティビティを完了すること。行き詰まった場合は記載の回復リンクを使う。

学習目標

離散分布について $E[X]$、$E[X^2]$、$\mathrm{Var}(X)=E[X^2]-E[X]^2$、標準偏差を補助なしで計算する。

手順

分布表の各行を先に計算してからまとめる。必須作業:下の 4 型分布・公平なサイコロ・Bernoulli(0.25) の 3 題。計算前に予測値を記録し、可能なところは厳密な分数で残す。

演習と予測記録

$\{0,1,2,3\}$ 上の $p=[0.5,0.25,0.125,0.125]$ で $E[X]$、$E[X^2]$、$\mathrm{Var}(X)$、$\sigma_X$ を求めよ。続いて公平なサイコロ($E[X^2]=91/6$)と $\mathrm{Bernoulli}(0.25)$ の $\mathrm{Var}$ を求めよ。

独立習得基準

すべての値が自力計算した参照の分数/小数に一致し、分散は二乗単位・$\sigma$ は元の単位で報告されていること。

公式ソースリソースと権利証跡

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

著者・提供機関: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapter 4: Discrete Random Variables (mean, expected value, standard deviation)

検証バージョンと日付: 2e web edition (Verified: 2026-10-30)

選定理由:

Step-by-step open examples of expected value and variance from distribution tables.

ソース前提知識:

High-school algebra; Day 25 probability foundations

安全フォールバック(オフライン回復性):

All required definitions, tables, and worked answers are reproduced locally in this lesson.

比較対象候補リソースと選定評価 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking Stanford copyright; public course notes No text extraction or redistribution permitted

CS229 Review of Probability Theory

著者・提供機関: Stanford CS229 course staff (Arian Maleki, Tom Do) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 2.5-2.6: Expectation, variance, common discrete distributions

検証バージョンと日付: 2020 public course notes (Verified: 2026-10-30)

選定理由:

Concise reference for Var(X)=E[X^2]-E[X]^2 and Bernoulli variance used in ML derivations.

ソース前提知識:

Multivariate calculus notation exposure

安全フォールバック(オフライン回復性):

Self-contained definitions and derivations in activity instructions and offline guide.

比較対象候補リソースと選定評価 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Co-selected: provides the gentler beginner narrative; CS229 provides the ML-oriented notation bridge.

MIT OCW 18.05 Introduction to Probability and Statistics ↗ compared_alternative [CC BY-NC-SA 4.0]

Strong full-course treatment with noncommercial/share-alike terms; heavier than the compact CS229 reference for this three-day block.

03 120 分

標本抽出・経験分布・最尤推定

予測と観測の証跡を記録した後にのみ補助を利用できます。

前提条件

前のアクティビティを完了すること。行き詰まった場合は記載の回復リンクを使う。

学習目標

シード固定の標本で経験分布を作り、標準誤差 $\sigma/\sqrt n$ で真の分布と比較し、ゼロカウントの失敗を含めてベルヌーイ分布とユニグラムの最尤推定を導出する。

手順

実行:python3 -c "import random, collections; random.seed(26); s=[random.randint(1,6) for _ in range(100)]; print(round(sum(s)/100,4), collections.Counter(s))". サイコロの標本平均の標準誤差は $\sigma/\sqrt n \approx 1.7078/10 \approx 0.1708$。60 回投げて表 36 回のコインの尤度は $p^{36}(1-p)^{24}$ で、$\hat p = 36/60$ で最大。ユニグラムでは MLE は $\hat p(w) = \mathrm{count}(w)/N$。

演習と予測記録

(a) シード固定の標本平均と、$1/6$ からずれた経験頻度を 1 つ報告せよ。(b) 60 回中 36 回表の $\hat p$ を対数尤度の微分を 0 に置いて導け。(c) コーパス "the cat sat on the mat the cat ran"($N=9$、観測 6 型)で 'the' と 'dog' のユニグラム MLE を示せ。モデルがホールドアウトのトークンに 0 を割り当てると何が壊れるか?

独立習得基準

シード固定の数値(平均 $3.47$、3 の目の不足)を正直に報告し、対数尤度から $\hat p = 0.6$ を導き、ゼロカウントの失敗と加算 1 の対処を説明できること。

公式ソースリソースと権利証跡

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

著者・提供機関: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapter 1: Sampling and Data (sampling, variation); Chapter 4 (estimating parameters)

検証バージョンと日付: 2e web edition (Verified: 2026-10-30)

選定理由:

Open coverage of sampling variability and estimation that motivates the MLE and standard-error work here.

ソース前提知識:

High-school algebra; Day 25 probability foundations

安全フォールバック(オフライン回復性):

All required definitions, simulations, and worked answers are reproduced locally in this lesson.

比較対象候補リソースと選定評価 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking PSF License Version 2

Python 3 random: Generate pseudo-random numbers

著者・提供機関: Python Software Foundation | オリジナル出所URL ↗

該当セクション・タイムスタンプ: random.seed, random.randint, random.sample, random.choices

検証バージョンと日付: Python 3.12 documentation (Verified: 2026-10-30)

選定理由:

Normative reference for the seeded draws used to build empirical distributions.

ソース前提知識:

Basic Python syntax

安全フォールバック(オフライン回復性):

Use the installed interpreter's help(random) and the included deterministic commands.

比較対象候補リソースと選定評価 (2)
NumPy random Generator documentation ↗ compared_deferred [BSD 3-Clause]

Faster vectorized sampling but adds a third-party dependency before the tensor track; deferred to the models-and-training days.

Python secrets module documentation ↗ compared_rejected_for_days_25_27 [PSF License Version 2]

Cryptographically secure randomness is unnecessary for reproducible statistical pedagogy and obscures the seed-based determinism the exercises require.

04 120 分

独立習得チェック:推定と標本抽出

独立習得チェック(AI 補助なし)。

前提条件

前のアクティビティを完了すること。行き詰まった場合は記載の回復リンクを使う。

学習目標

見知らぬ推定問題を自力で解き、各結果の背後にある統計的仮定を述べる。

手順

このチェック中は AI・参照資料は使わず四則演算のみ。まず予測を記録し、4 問すべてを解いてから見直し、誤りは回復リンクをたどる。 最初の無支援の試行は変更せず保存する。その後の誤りの見直しと支援つき回復は別段階であり、抜けた概念は、答えを事前に見せない新しい同等の無支援チェックに合格して初めて修復済みとみなす。 再チェック(回復後のみ・無支援・ヒントなし):(a) $\{0,1,2,3\}$ 上の $p=[0.2,0.3,0.4,0.1]$ で $E[X]$ と $\mathrm{Var}(X)$ を求めよ。(b) $P(\text{3 回投げて少なくとも 1 回 6})$ を求めよ。(c) 15 回中 9 回表:$\hat p$ とその近似標準誤差を答えよ。(d) 有限標本の比率が真の $p$ と一致しなくてよい理由を一文で説明せよ。このカードは再チェックの答えを載せない:習得基準と同じ基準(正しい値、i.i.d. と有限標本の仮定の明示)で採点し、解き終えてから別の方法($\mathrm{Var}=E[(X-E[X])^2]$ の直接計算、または $6^3$ 通りの全列挙)でのみ検算する。(a) を誤ったら day-26-act-01(分布表の妥当性)と day-26-act-02(期待値・分散)、(b) は day-25-act-02(独立性)と day-25-act-01(数え上げ)、(c)-(d) は day-26-act-03(標本抽出・標準誤差・最尤推定)で回復する。

演習と予測記録

(a) $\{0,1,2,3\}$ 上の $p=[0.1,0.2,0.4,0.3]$ で $E[X]$ と $\mathrm{Var}(X)$ を求めよ。(b) $P(\text{4 回投げて少なくとも 1 回 6})$ を求めよ。(c) 20 回中 14 回表:$\hat p$ を答え、真の $p$ がなお異なりうる理由を 1 つ挙げよ。(d) 有限標本の平均が $E[X]$ と一致しなくてよい理由を一文で説明せよ。

独立習得基準

自力の値が $1.9$、$0.89$、$0.5177$、$0.7$ に一致し、i.i.d. と有限標本の仮定が述べられ、誤りは回復リンクにつながり、抜けた概念は新しい同等の無支援チェックでのみ修復されること。

公式ソースリソースと権利証跡

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

著者・提供機関: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapters 1 and 4 review: sampling, distributions, expectation, variance

検証バージョンと日付: 2e web edition (Verified: 2026-10-30)

選定理由:

Open review coverage aligned with this day's assessment scope.

ソース前提知識:

High-school algebra; Day 25 probability foundations

安全フォールバック(オフライン回復性):

The assessment is self-contained with original items and worked reference answers.

比較対象候補リソースと選定評価 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking Stanford copyright; public course notes No text extraction or redistribution permitted

CS229 Review of Probability Theory

著者・提供機関: Stanford CS229 course staff (Arian Maleki, Tom Do) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 2.4-3: random variables, expectation, variance, maximum likelihood

検証バージョンと日付: 2020 public course notes (Verified: 2026-10-30)

選定理由:

Reference for estimation and MLE concepts this assessment checks without assistance.

ソース前提知識:

Multivariate calculus notation exposure

安全フォールバック(オフライン回復性):

The assessment is self-contained with original items and worked reference answers.

比較対象候補リソースと選定評価 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Co-selected: provides the gentler beginner narrative; CS229 provides the ML-oriented notation bridge.

MIT OCW 18.05 Introduction to Probability and Statistics ↗ compared_alternative [CC BY-NC-SA 4.0]

Strong full-course treatment with noncommercial/share-alike terms; heavier than the compact CS229 reference for this three-day block.