1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
HACTEHA [7]
3 years ago
13

Create a function that will perform linear interpolation from a set of measured data stored in a list or array. The function sho

uld 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
Computers and Technology
1 answer:
wel3 years ago
8 0

Answer:

This question is incomplete, here is the complete question:

Python

a) You should 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. 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.

Explanation:

from __future__ import division

from cStringIO import StringIO

import numpy as np

from scipy.interpolate import RectBivariateSpline

np.set_printoptions( 1, threshold=100, edgeitems=10, suppress=True )

   # a file inline, for testing --

myfile = StringIO( """

# T P1 P2 P3 P4

0,   80,100,150,200

75, 400,405,415,430

100, 450,456,467,483

150, 500,507,519,536

200, 550,558,571,589

""" )

   # file -> numpy array --

   # (all rows must have the same number of columns)

TPU = np.loadtxt( myfile, delimiter="," )

P = TPU[0,1:] # top row

T = TPU[ 1:,0] # left col

U = TPU[1:,1:] # 4 x 4, 400 .. 589

print "T:", T

print "P:", P

print "U:", U

interpolator = RectBivariateSpline( T, P, U, kx=1, ky=1 ) # 1 bilinear, 3 spline

   # try some t, p --

for t, p in (

   (75, 80),

   (75, 200),

   (87.5, 90),

   (200, 80),

   (200, 90),

   ):

   u = interpolator( t, p )

   print "t %5.1f p %5.1f -> u %5.1f" % (t, p, u)

You might be interested in
The _______ number system allows digital devices to represent virtually any number simply by using 0s and 1s.â
zhuklara [117]
The answer is <span>Digital data 

</span>
4 0
3 years ago
How to construct a 112.5 degree angle?
worty [1.4K]
You can construct it with a protractor. 
7 0
3 years ago
How do you go about placing a picture in your question?
rodikova [14]

when you are asking your question you can click on the link down at the bottom and when it pops up all your files click the one who want to send

plz mark brainliest lol seemed like an easy question but i need them to rank up so yea lol

6 0
3 years ago
Read 2 more answers
Which of the following is true? AChecks and Debit Cards both withdraw money directly from a bank account. BChecks are the most w
Nezavi [6.7K]
I think it would be B.
6 0
3 years ago
Which component of the computer keeps the operating system when the computer is running​
Brums [2.3K]

The CPU performs the instructions and writes the data back into your computer's random access memory or RAM. RAM temporarily stores data while your computer is running.

4 0
3 years ago
Other questions:
  • How do type declaration statements for simple variables affect the readability of a language, considering that some languages do
    10·1 answer
  • Olivia needs to get permission to use a graph of data gathered by a trade association she plans to include the graph in a report
    10·2 answers
  • Please check my answer! (Java)
    13·1 answer
  • When searching the web software programs called fetch a few web pages and then they follow the links on those pages and fetch th
    9·2 answers
  • A variable that can be modified from anywhere within a program is called a?
    5·1 answer
  • Which of the these is tool for creating mobile apps? A:C# B:Apple Pie C:Appy Pie D:C++​
    8·2 answers
  • Robert gets home from school at 3 p.M. His mom has to leave for her shift at work at 3:15 and she wants him to watch his baby br
    9·1 answer
  • Mrs. Zoo gave out the rubric for our essay. She stated that our essay should be complete by Friday of that week. I didn't have t
    13·1 answer
  • Imagine that you just received a summer job working for a computer repair shop one of your first task is to take apart a compute
    14·1 answer
  • Answer all of the questions,
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!