HW14: Interpolation and Models#
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d, CubicSpline
from scipy.optimize import curve_fit
import pandas as pd
Problem 1: Interpolation#
Given the data xg
and yg
below. Find the linear interpolate yw corresponding to xw=0.54
. Also find the cubic spline (read the notes) value of y at the same point. The xg
and yg
values are computed from \(y=f(x)=\exp(4x)\). Find the relative error between your interpolants and the exact value. The relative error is given by \(\epsilon = |(y-y_{exact})/y_{exact}|\).
xg = np.array([0,0.2,0.4,0.8,1.0])
yg = np.exp(4.0*xg)
xw = 0.54
yexact = np.exp(4.0*xw)
Problem 2: Cars and Trucks Data Set#
Complete the regression with the cars and trucks data set that is referenced in Module 14 on data science to determine what the R2 and MAPE values are if you also screen the data such that the odometer readings are between 1000 and 190,000 miles. You can use the linear or the logistic method for regression.
Problem 3: Data Science with DOW#
Complete the Last Challenge from class with Krystian Perez from DOW.