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
Which of the following correctly describes a work in the public domain?
Anarel [89]

Answer:

B

Explanation:

I took the test got a 100

8 0
3 years ago
When _______ wordart, you need to consider both the font size of the text and the size of the text box that contains wordart?
padilas [110]
The correct answer is resizing. If you're making a logo and creating wordart. you have to care about resizing because the art needs to be clearly visible and appealing no matter the size. If you place it in a box, you have to care that it doesn't go over the edges of the box or anything similar that might seem appalling.
4 0
3 years ago
What shoul i get, Airpods or a ps4 cooling fan ???
Fynjy0 [20]

Answer:

Airpods, there is ps5 coming out

Explanation:

3 0
2 years ago
Read 2 more answers
Who still plays old Nintendo 64 games?
Lesechka [4]

Answer:

I play Nintendo 64 games when I was young. I use to love playing Mario 64 as well.

8 0
2 years ago
Read 2 more answers
How does a computer resolve a domain name into an ip address?
Yanka [14]

Answer:

Using the DNS service.

Explanation:

The computer sends a UDP packet with the domain name in it to port 53 of the configured DNS server, and expects a reply with the IP address of that domain.

8 0
3 years ago
Other questions:
  • An organization’s IRP prioritizes containment over eradication. An incident has been discovered where an attacker outside of the
    5·1 answer
  • For homework, we have to figure out what's in the picture. It's " too close to tell " but I can't figure out what it is. Any ide
    11·1 answer
  • Where could an identity theft access your personal information
    9·2 answers
  • TRUE OR FALSE: Individuals involved in surveillance prior to a terrorist attack are always well-trained and equipped.
    13·1 answer
  • Which option is the strongest password?
    7·2 answers
  • Examine the efficiency the various recovery algorithms used in deadlock handling
    10·1 answer
  • Pls tell me the answer pls i need the answer
    6·2 answers
  • What is this?
    15·2 answers
  • What is the computer that is connected to a<br> server
    8·2 answers
  • Why is computer science hardware needed to solve problems with computers?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!