Two Sigma research workflows may represent a signal as values sampled at irregular x-coordinates. Given these samples, evaluate the signal at multiple query coordinates using piecewise linear interpolation.
Implement linear_interpolate(x_values, y_values, queries). For each query q, find the two neighboring sample points (x_i, y_i) and (x_{i+1}, y_{i+1}) such that x_i <= q <= x_{i+1}, then return:
y_i + (q - x_i) * (y_{i+1} - y_i) / (x_{i+1} - x_i)
A query equal to a sample coordinate must return the corresponding sample value. Queries are guaranteed to lie within the range of the sample coordinates, so extrapolation is not required. Return results in the same order as queries.
x_values: a strictly increasing list of n numbers.y_values: a list of n numbers corresponding to x_values.queries: a list of m numbers to evaluate.m floating-point numbers.def linear_interpolate(x_values, y_values, queries):