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.
Ratkaisu
Kiitos palautteestasi!
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Awesome!
Completion rate improved to 7.14
Law of Large Numbers via Simulation
Pyyhkäise näyttääksesi valikon
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.
Ratkaisu
Kiitos palautteestasi!
single