Menu

Please Help Use Python Write Code 6a 6b Please Give Correct Code Thanks Sample 5a 5b Given Q43889234

0 50 100 150 200 250 2) Compute the relative error in the rounded representation of 100 values of x equally spaced across thePlease help me to use python to write thiscode 6a and 6b, please give me correct code, thanks. Sample for 5aand 5b given

5a) Compute the absolute error in the rounded representation of 250 values of x equally spaced across the interval (-15, 15].5b) Plot the absolute error as computed in 5a. matplotlib inline #magic command above makes plot show up in notebook import m

0 50 100 150 200 250 2) Compute the relative error in the rounded representation of 100 values of x equally spaced across the interval (–15, 15). ) Plot the relative error as computed in 5a. =) What is machine epsilon for this floating point system? Explain how you arrived at your answer and how that answer lates to your plot of relative error. 5a) Compute the absolute error in the rounded representation of 250 values of x equally spaced across the interval (-15, 15]. import numpy as np #importing mean absolute error from sci-kit learn from sklearn.metrics import mean_absolute_error # creating an array of 250 evenly spaced values using linspace function from the numpy package sample = np.linspace (-15, 15, num = 250) print (sample) # rounding each value from the sample rounded = (round(i) for i in sample) print (rounded) # calculating absolute error from sample and rounded values abs_error = [] for i in range(len (sample)): abs_error.append(abs (sample[i] – rounded[i])) # printing the absolute error print(abs_error) PAGES IN 5b) Plot the absolute error as computed in 5a. matplotlib inline #magic command above makes plot show up in notebook import matplotlib.pyplot as plt # plotting original sample values plt.plot(sample) # plotting rounded values plt.plot(rounded) # plotting the absolute error plt.plot(abs_error) # adding legend plt.legend( (‘sample’, ’rounded’, ‘absolute error’)). plt.show() #insert additional code here sample rounded absolute error 0 50 100 150 200 250 Show transcribed image text 0 50 100 150 200 250 2) Compute the relative error in the rounded representation of 100 values of x equally spaced across the interval (–15, 15). ) Plot the relative error as computed in 5a. =) What is machine epsilon for this floating point system? Explain how you arrived at your answer and how that answer lates to your plot of relative error.
5a) Compute the absolute error in the rounded representation of 250 values of x equally spaced across the interval (-15, 15]. import numpy as np #importing mean absolute error from sci-kit learn from sklearn.metrics import mean_absolute_error # creating an array of 250 evenly spaced values using linspace function from the numpy package sample = np.linspace (-15, 15, num = 250) print (sample) # rounding each value from the sample rounded = (round(i) for i in sample) print (rounded) # calculating absolute error from sample and rounded values abs_error = [] for i in range(len (sample)): abs_error.append(abs (sample[i] – rounded[i])) # printing the absolute error print(abs_error) PAGES IN
5b) Plot the absolute error as computed in 5a. matplotlib inline #magic command above makes plot show up in notebook import matplotlib.pyplot as plt # plotting original sample values plt.plot(sample) # plotting rounded values plt.plot(rounded) # plotting the absolute error plt.plot(abs_error) # adding legend plt.legend( (‘sample’, ’rounded’, ‘absolute error’)). plt.show() #insert additional code here sample rounded absolute error 0 50 100 150 200 250

Expert Answer


Answer to Please help me to use python to write this code 6a and 6b, please give me correct code, thanks. Sample for 5a and 5b giv…

OR