Create a function called my_linear_interpolation() and add it to your HW4.py file. This function should use the technique discussed in lecture to perform interpolation of data using linear spline functions as covered in class. Your function should take in the following input in the following order: • vector(float) x: the vector of data that are the inputs for which you wish to interpolate within • vector(float) fx: the vector of data that are the outputs you want to perform interpolation on • vector(float) xi: A vector of points the user wishes to interpolate fx at with a linear spline And then output the following: • vector(float) fxi: the vector of the same length as xi with the interpolated values at those respective points Hint: From lecture we know that we can determine the interpolated values by finding the two nearest points from the data and defining a straight line between those two points. Write in Python.
Added by Michele Q.
Step 1
Step 1: Define the function my_linear_interpolation() with the specified input parameters x, fx, and xi. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 65 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
In Python, using classes: The equation of a straight line is "y = ax + b" (or perhaps "y = mx + c"). The coefficients a and b completely describe the line. Write a method in the Point class so that if a point instance is given another point, it will compute the equation of the straight line joining the two points. It must return the two coefficients as a tuple of two values. For example: >>> print(Point(4, 11).get_line_to(Point(6, 15))) >>> (2, 3)
Akash M.
In the field of remote sensing, a common task that comes up is coordinate conversion. Two common coordinate systems are geodetic coordinates, consisting of latitude, longitude, and altitude (LLA) and geocentric coordinates, also called Earth-centered, Earth-fixed (ECEF). I have csv that is a bunch of data in LLA coordinates. It is your task to write a program that returns the ECEF velocity vector of the object at any requested time. I need the following (1) Read CSV (2) Convert LLA to ECEF (3) Calculate ECEF velocity at the time points given in the input file (4) Interpolate ECEF velocity for any requested time I need this to be in python. I can use Numpy, SciPy, pandas, and any other library .
Supreeta N.
Using the same datasets as in problem 2, utilize numpy's polyfit function to find the slope and intercept of the regression line. (the data sets are x = [2.3, 3.1, 4.4, 5.5, 6.1, 7.7, 8.8] and y = [3.2, 4.4, 4.0, 5.9, 6.5, 7.1, 8.0])
Lucas F.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD