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ösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Awesome!
Completion rate improved to 7.14
Law of Large Numbers via Simulation
Swipe um das Menü anzuzeigen
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ösung
Danke für Ihr Feedback!
single