Law of Large Numbers via Simulation
Swipe to start coding
You will implement a Python function that demonstrates the law of large numbers using samples drawn from a standard normal distribution.
Your task is to complete the required parts of the code so that:
- The function accepts an integer
n_samples. - Generates
n_samplesindependent samples from a normal distribution with mean 0 and standard deviation 1 using NumPy. - Computes the running mean after each newly drawn sample.
- Plots the running mean against the sample index using Matplotlib.
- Draws a horizontal line at 0, representing the theoretical mean of the distribution.
Follow the placeholders in the task code.
Use only numpy and matplotlib.
Løsning
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Awesome!
Completion rate improved to 7.14
Law of Large Numbers via Simulation
Stryg for at vise menuen
Swipe to start coding
You will implement a Python function that demonstrates the law of large numbers using samples drawn from a standard normal distribution.
Your task is to complete the required parts of the code so that:
- The function accepts an integer
n_samples. - Generates
n_samplesindependent samples from a normal distribution with mean 0 and standard deviation 1 using NumPy. - Computes the running mean after each newly drawn sample.
- Plots the running mean against the sample index using Matplotlib.
- Draws a horizontal line at 0, representing the theoretical mean of the distribution.
Follow the placeholders in the task code.
Use only numpy and matplotlib.
Løsning
Tak for dine kommentarer!
single