Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me to use python to write this code 6a and 6b, please give me correct code, thanks. Sample for 5a and 5b given
Please help me to use python to write this code 6a and 6b, please give me correct code, thanks. Sample for 5a and 5b given
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 250Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started