Premium problem44. Law of Large Numbers

Easy Locked

Simulate n Bernoulli(p) trials and return the running sample mean after each one, so element i is the mean of the first i + 1 trials.

The sequence wanders early and settles toward p. That convergence is the law of large numbers, and it is a different claim from the central limit theorem: this one is about where the mean goes, not about the shape of its distribution.

Seed np.random.seed(seed) inside solve, immediately before drawing.

Input

p = 0.5
n = 10
seed = 0

Output

[0.0, 0.0, 0.0, 0.0, 0.2, 0.16666666666666666, 0.2857142857142857, 0.25, 0.2222222222222222, 0.3]

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)