Block 4: Expectation, variance and the law of large numbers
Week 10 · Probability II · Imai §6.3.5, 6.4.1 · about 4 min
NoteHow this works
Run each cell with Run Code, look at the output, then answer the question at the end of the block. Every cell is editable; Start Over resets it. Errors are information: read them.
Expectation \(E(X)\) is the long-run average; variance \(V(X) = E((X - E(X))^2)\). For Bernoulli(\(p\)): \(E = p\), \(V = p(1-p)\). For Binomial(\(n\), \(p\)): \(E = np\), \(V = np(1-p)\).
1. Theoretical vs. sample variance
2. The law of large numbers
The sample mean converges to \(E(X)\) as the sample size grows. We plot the running mean cumsum(x) / 1:sims of 1,000 draws from Binomial(10, 0.2).
Conclusion: Where does the running mean end up, and why?
E(X) = np = 2. The path is noisy for small samples and settles at 2: the law of large numbers. Theory 0.25, sample variance 0.2502.