CommencerCommencer gratuitement

Reasons for Modeling: Interpolation

One common use of modeling is interpolation to determine a value "inside" or "in between" the measured data points. In this exercise, you will make a prediction for the value of the dependent variable distances for a given independent variable times that falls "in between" two measurements from a road trip, where the distances are those traveled for the given elapse times.

context figure

Cet exercice fait partie du cours

Introduction to Linear Modeling in Python

Afficher le cours

Instructions

  • Inspect the predefined data arrays, times and distances, and the preloaded plot.
  • Based on your rough inspection, estimate the distance_traveled away from the starting position as of elapse_time = 2.5 hours.
  • Assign your answer to distance_traveled.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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))
Modifier et exécuter le code