Please complete coding assignment in Python

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Please complete coding assignment in Python! Thank you!

import numpy as np
def bilinear_interp(query, X, Y, Z):
"""Bi-linear interpolation on two-dimensional grid.
Parameters
query tuple, (x,y)
Coordinates of query point to interpolate
X 1d array of length m, *sorted strictly ascending*
Coordinates of data points along first dimension
Y 1d array of length n, *sorted strictly ascending*
Coordinates of data points along second dimension
Z 2d array of shape (m, n)
I
Values of the dependent variable z on data points. Z[i, j] is the value
of z at the data point with coordinates (✗[i], Y[j]).
Returns
zqscalar
Interpolated z value on query point. Bi-linear interpolation uses a
weighted average of values from the 4 nearest neighbor data points.
Interpolated value always equals data value if query point is a data
point. If query point is outside data range the interpolated value is
np.nan.
(X.size, Y.size)),\
"I
assert (X.ndim == Y.ndim == 1) and (Z.shape
"Dimension mismatch, check the docstring.'
m, nZ.shape
x, y query
zq = 0
### START YOUR CODE HERE ###
###
### STEP 0: get the easy stuff out of the way. If the query point is "out
#3#23% of bounds", just return the special value np.nan.
###
### STEP 1a: Find i such that X[i] <= x < X[i+1]
### STEP 1b: Find j such that Y[j] <= y < Y[j+1]
###
### There are many ways of doing this, and I don't require your solution to
### be similar to mine. The goal is to get the correct indices
### in ALL cases. (Note that the interpolation formula below works just as
%%% well if the condition is changed to X[i] < x <= X[i+1], and the same
%23% 23%23 for y of course. So if a query coordinate is equal to the largest data
### coordinate you are technically using that second condition.)
###
### STEP 2: Use bi-linear interpolation formula to calculate and return the
###
interpolated value.
### THAT'S IT
##########1
return zq
##########
Transcribed Image Text:import numpy as np def bilinear_interp(query, X, Y, Z): """Bi-linear interpolation on two-dimensional grid. Parameters query tuple, (x,y) Coordinates of query point to interpolate X 1d array of length m, *sorted strictly ascending* Coordinates of data points along first dimension Y 1d array of length n, *sorted strictly ascending* Coordinates of data points along second dimension Z 2d array of shape (m, n) I Values of the dependent variable z on data points. Z[i, j] is the value of z at the data point with coordinates (✗[i], Y[j]). Returns zqscalar Interpolated z value on query point. Bi-linear interpolation uses a weighted average of values from the 4 nearest neighbor data points. Interpolated value always equals data value if query point is a data point. If query point is outside data range the interpolated value is np.nan. (X.size, Y.size)),\ "I assert (X.ndim == Y.ndim == 1) and (Z.shape "Dimension mismatch, check the docstring.' m, nZ.shape x, y query zq = 0 ### START YOUR CODE HERE ### ### ### STEP 0: get the easy stuff out of the way. If the query point is "out #3#23% of bounds", just return the special value np.nan. ### ### STEP 1a: Find i such that X[i] <= x < X[i+1] ### STEP 1b: Find j such that Y[j] <= y < Y[j+1] ### ### There are many ways of doing this, and I don't require your solution to ### be similar to mine. The goal is to get the correct indices ### in ALL cases. (Note that the interpolation formula below works just as %%% well if the condition is changed to X[i] < x <= X[i+1], and the same %23% 23%23 for y of course. So if a query coordinate is equal to the largest data ### coordinate you are technically using that second condition.) ### ### STEP 2: Use bi-linear interpolation formula to calculate and return the ### interpolated value. ### THAT'S IT ##########1 return zq ##########
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education