Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Coding Create a function that will perform linear interpolation from a set of measured data. The function should take as input a list of

Python Coding

Create a function that will perform linear interpolation from a set of measured data. The function should take as input a list of values at which samples were taken, and then another list giving the measurements (you can assume each measurement is a single value) at those values. It should also take in a query value, and should give the best estimate it can of the value at that query. Be sure to handle values that are outside of the range, by extrapolating. You should write a program that allows you to test your function by reading the lists from a file where each line of the file is a pair of numbers separated by spaces: the value where the sample was taken, and the measurement at that value. Your program should ask the user for the name of the file and for a query value. Important: The two lists will correspond to each other: i.e. for the i-th value in the first list, the measurement will be the i-th element of the second list (these are called parallel lists or arrays). But, you should not assume that the input values are in increasing/decreasing order. That is, the values in the first list can be in any random ordering, not necessarily from smallest to largest or largest to smallest. You will have to account for this in your program, and there is more than one way to do so. As a team, you should discuss what options you can think of to handle the data arriving in any order like that, and decide what you think the best option for handling it is.

Extend your program from part (a) so that it will handle not just single values but vector data. Your program should ask a user for a file name, and the number of dimensions, n, of the vector data. It should then read from the file, assuming the values at which measurements are taken are the first entry per line, and then there will be n entries, all space-separated. You may find it easier to store your vector data in numpy arrays. Your interpolation function should return the vector data either using tuples or using arrays from the numpy module.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago