Question: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np import random import sys if __name__ == '__main__': # default dim = 1

from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np import random import sys

if __name__ == '__main__':

# default dim = 1 numsamples = 100

if len(sys.argv) > 1: dim = int(sys.argv[1]) if dim > 3: print( "Dimension must be 3 or less; capping at 3") if len(sys.argv) > 2: numsamples = int(sys.argv[2]) print("Running with dim = " + str(dim), \ " and numsamples = " + str(numsamples))

# Generate data from (Univariate) Gaussian if dim == 1: # mean and standard deviation in one dimension mu = 0 sigma = 1.0 x = np.random.normal(mu, sigma, numsamples) y = np.zeros(numsamples,) else: # mean and standard deviation in three dimension print("Dimension not supported") exit(0)

#TODO: Get the current estimate of the sample mean

#TODO: Get the current estimate of the sample variance

from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np

import random import sys if __name__ == '__main__': # default dim =

if -_name_- -- '-__main__': # default dim - 1 numsamples = 100 if len(sys. argv) > 1: dim = int(sys.argv[1]) if dim > 3: print("Dimension must be 3 or less; capping at 3") if len(sys.argv) > 2: numsamples = int(sys.argv[2]) print("Running with dim = " + str(dim), \ and numsamples =" + str(numsamples)) # Generate data from (Univariate) Gaussian if dim == 1: # mean and standard deviation in one dimension mu - 9 sigma = 1.0 x - np.random.normal (mu, sigma, numsamples) y = np.zeros(numsamples, else: # mean and standard deviation in three dimension print("Dimension not supported") exit(0) #TODO: Get the current estimate of the sample mean #TODO: Get the current estimate of the sample variance (a) (5 MARKS] Change the code such that it prints the mean and variance of your samples, using Numpy functions. You are only required to add these two lines in simulate.py. (b) [7 MARKS) Run the code for 10 samples with dim=1 and 2 = 1.0. Write down the sample average that you obtain. Now do this another 4 times, giving you 5 estimates of the sample average M1, M2, M3, M4 and Ms. What is the sample variance of these 5 estimates? (c) (7 MARKS] Now run the same experiment, but use 100 samples for each sample average estimate. What is the sample variance of these 5 estimates? How is it different from the variance when you used 10 samples to compute the estimates? if -_name_- -- '-__main__': # default dim - 1 numsamples = 100 if len(sys. argv) > 1: dim = int(sys.argv[1]) if dim > 3: print("Dimension must be 3 or less; capping at 3") if len(sys.argv) > 2: numsamples = int(sys.argv[2]) print("Running with dim = " + str(dim), \ and numsamples =" + str(numsamples)) # Generate data from (Univariate) Gaussian if dim == 1: # mean and standard deviation in one dimension mu - 9 sigma = 1.0 x - np.random.normal (mu, sigma, numsamples) y = np.zeros(numsamples, else: # mean and standard deviation in three dimension print("Dimension not supported") exit(0) #TODO: Get the current estimate of the sample mean #TODO: Get the current estimate of the sample variance (a) (5 MARKS] Change the code such that it prints the mean and variance of your samples, using Numpy functions. You are only required to add these two lines in simulate.py. (b) [7 MARKS) Run the code for 10 samples with dim=1 and 2 = 1.0. Write down the sample average that you obtain. Now do this another 4 times, giving you 5 estimates of the sample average M1, M2, M3, M4 and Ms. What is the sample variance of these 5 estimates? (c) (7 MARKS] Now run the same experiment, but use 100 samples for each sample average estimate. What is the sample variance of these 5 estimates? How is it different from the variance when you used 10 samples to compute the estimates

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!