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 RFC reserves three ranges of IP addresses for private use - a single Class A (10.0.0.0-10.255.255.255), 16 Class Bs (172.1
erica [24]

Answer:

The answer is "1918".

Explanation:

The RFC stands for "remote function call", it is also known as an abbreviated form. It is an application, that responses in a technical online design Task Force, it is also known as a document, which was prepared for review by shareholders to collects some information.  

The RFC reverses is also known as an idea, that uses IP version 4 to reverse the IP address, this process is done by TCP/IP protocol, which is defined under RFC 1918.  

4 0
3 years ago
For this problem, you will write a function standard_deviation that takes a list whose elements are numbers (they may be floats
Evgesh-ka [11]

Answer:

  1. import math  
  2. def standard_deviation(aList):
  3.    sum = 0
  4.    for x in aList:
  5.        sum += x  
  6.    
  7.    mean = sum / float(len(aList))
  8.    sumDe = 0
  9.    for x in aList:
  10.        sumDe += (x - mean) * (x - mean)
  11.    
  12.    variance = sumDe / float(len(aList))
  13.    SD = math.sqrt(variance)
  14.    return SD  
  15. print(standard_deviation([3,6, 7, 9, 12, 17]))

Explanation:

The solution code is written in Python 3.

Firstly, we need to import math module (Line 1).

Next, create a function standard_deviation that takes one input parameter, which is a list (Line 3). In the function, calculate the mean for the value in the input list (Line 4-8). Next, use the mean to calculate the variance (Line 10-15). Next, use sqrt method from math module to get the square root of variance and this will result in standard deviation (Line 16). At last, return the standard deviation (Line 18).

We can test the function using a sample list (Line 20) and we shall get 4.509249752822894

If we pass an empty list, a ZeroDivisionError exception will be raised.

3 0
3 years ago
3. Find the best.
Tamiku [17]

Answer:

1. is the answer

Explanation:

<h2>mark me as brainlest</h2>

6 0
2 years ago
Which type of image is composed of lines, curves, and fills?
Nataliya [291]
<h2>Answer: Vectors</h2>

Explanation:

4 0
3 years ago
Why is Thomas Jefferson considered an accomplished man , or a Renaissance man?​
lesantik [10]
The term “Renaissance man” means for a very clever person to be good at many different things.
4 0
3 years ago
Other questions:
  • How is the Task Manager helpful in displaying which resources your computer is using and how fast?
    5·2 answers
  • I am confused about joins in sql.
    8·2 answers
  • RDBMS stands for_________________
    12·1 answer
  • What are three reasons teens might start drinking alcohol??
    7·2 answers
  • Variables set equal to patterns are said to be:_______.
    7·1 answer
  • The ____ aggregate function finds the largest value
    10·1 answer
  • What is the output of doublec= 12.0 / 5 Systemoutprintln (c)
    8·1 answer
  • What are the characteristics of a good text-based adventure game? In other words, what are some features that should be in the g
    7·1 answer
  • Which item is not part of a college application
    11·1 answer
  • Give five example of a dedicated device ​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!