Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions