Shows expected value as a probability-weighted average (highlighting one term x·P(x) at a time) and as the long-run average: a running sample mean from repeated draws converges toward the theoretical E[X]. A bottom panel animates linearity by varying constants a and b and displaying E[aX+b] = aE[X]+b.
Deterministic per-cycle sampling uses a simple xorshift32 PRNG so the animation is stable. The right panel plots the running mean approaching a fixed E[X] line; the left panel cycles a highlighted x·P(x) term. Layout scales with canvas size using scale=Math.min(w,h)/240 and snap-to-grid rounding for a blocky aesthetic.