Complete the code to generate 1000 random samples from a normal distribution with mean 0 and standard deviation 1.
samples = np.random.normal(loc=0, scale=[1], size=1000)
The standard deviation (scale) for a standard normal distribution is 1.
Complete the code to generate 500 random samples from a uniform distribution between 10 and 20.
samples = np.random.uniform(low=[1], high=20, size=500)
The lower bound (low) for the uniform distribution is 10.
Fix the error in the code to generate 100 samples from a binomial distribution with 10 trials and success probability 0.5.
samples = np.random.binomial(n=10, p=[1], size=100)
The probability p must be between 0 and 1. 0.5 is valid.
Fill both blanks to create a dictionary of sample means from 1000 samples each, for sample sizes 10 and 50, using a normal distribution with mean 0 and std 1.
means = {size: np.mean(np.random.normal(loc=0, scale=1, size=[1])) for size in [[2], 50]}The first blank is the sample size for the np.random.normal call, which should match the size variable in the dictionary comprehension. The second blank is the first sample size in the list, 10.
Fill all three blanks to create a dictionary of sample variances from 500 samples each, for sample sizes 20 and 100, using a uniform distribution between 0 and 1.
variances = {size: np.var(np.random.uniform(low=0, high=[1], size=[2]), ddof=[3]) for size in [20, 100]}The high parameter is 1 for uniform distribution between 0 and 1. The size is 500 samples. The ddof parameter is 1 to get the sample variance.