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
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 7.14
Law of Large Numbers via Simulation
Svep för att visa menyn
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
Tack för dina kommentarer!
single