開始使用免費開始

建模的理由:內插

建模的一個常見用途是透過「內插」來推定落在量測資料點「之內/之間」的數值。在這個練習中,你要根據自變數 times 的某個給定值,為依變數 distances 做出落在兩個公路旅行量測點「之間」的預測;其中 distances 表示在給定經過時間內所行駛的距離。

context figure

本練習屬於課程

Python 線性建模入門

檢視課程

練習說明

  • 檢視預先定義的資料陣列 timesdistances,以及已載入的圖。
  • 根據你的初步觀察,估計在 elapse_time = 2.5 小時時,從起點出發後的 distance_traveled
  • 將你的答案指定給 distance_traveled

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Compute the total change in distance and change in time
total_distance = ____[-1] - ____[0]
total_time = ____[-1] - ____[0]

# Estimate the slope of the data from the ratio of the changes
average_speed = total_distance / total_time

# Predict the distance traveled for a time not measured
elapse_time = 2.5
distance_traveled = average_speed * elapse_time
print("The distance traveled is {}".format(distance_traveled))
編輯並執行程式碼