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
When somthing is trustworthy we call it what?
Gnom [1K]

Answer:

dependable

Explanation:

5 0
3 years ago
Read 2 more answers
Researchers conducted a 'natural experiment' to examine the effects of on-site food services on weight gain among first-year col
anygoal [31]

Answer:

On-site food services is the INDEPENDENT variable and the weight gain is the DEPENDENT variable

Explanation:

Variables can be dependent or independent. An independent variable is the one used by the researcher to test its degree of influence on the dependent variable. The dependent variable, as the name implies, relies on changes in the independent variable to effect its own changes.

In the question, it is obvious that weight gain among the first year students is dependent on on-site food services

7 0
3 years ago
Barbara has three computers connected to the same network in her home. What
Anastaziya [24]

Answer:

LAN

Explanation:

i am not sure but I think it is lan

5 0
3 years ago
In 1-2 sentences, describe how you would open a new word processing document.
Gennadij [26K]
This depends on what computer and
System it's running on
4 0
3 years ago
Semiconductor memory is used mainly for primary storage even with its high cost. In another hand, the magnetic tape is the cheap
Charra [1.4K]
<span>Storage costs of magnetic tape are much lower than semiconductor storage (chip storage), but they take longer to access because they are not on-board the system and have to be added manually. Chip memory, on the other hand, can be used as primary storage for a system even with a higher cost because it's typically directly connected to the system board and is much more easily accessible by the system.</span>
8 0
3 years ago
Other questions:
  • What is workflow? how do you create your own workflow?
    15·1 answer
  • which one of these steps describe saving a newly created file. click on the save icon. minimize the file. name the file. select
    12·2 answers
  • You have just driven to the Hewlett-Packard site in Corvallis to field-interview a programmer. You sit down in a conference room
    6·1 answer
  • An office employee working in a payroll department uses a customized program to log hours employees have worked. The customized
    12·2 answers
  • Which actions help to protect a computer and keep it running properly? Check all that apply.
    10·1 answer
  • What is better for the sd card use as portable storage or use as internal storage?
    15·1 answer
  • Write an algorithm that gets as input your current credit card balance, the total dollar amount of new purchases, and the total
    8·1 answer
  • Please Help, Thank you!
    5·1 answer
  • Write a simple algorithm in pseudocode that asks the user their favourite colour and then agrees with their choice, quoting the
    15·1 answer
  • Write a program to output 3 lines of text with the following information:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!