Question: Python3 code question Change the code such that it prints the mean and variance of your samples, using Numpy functions. You are only required to

Python3 code question

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 this python file. These two to-do lines are in bold font. This is in python3. Thank you in advance

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

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

Python3 code question Change the code such that it prints the mean

and variance of your samples, using Numpy functions. You are only required

from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np import random import sys # default dim - 1 - 100 numsamples 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]) + str(dim), print("Running with 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

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!