英文:
How does LinearNDinterpolator really work? The theory behind it?
问题
from scipy.interpolate import LinearNDInterpolator
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1, 1, 5, 6])
y = np.array([1, 5, 5, 5])
z = [2, 6, 10, 11]
points = np.array(list(zip(x, y)))
values = np.array(z)
i = 2
j = 4.5
Linear = LinearNDInterpolator(points, values)
r = Linear(i, j)
print("Linear %s" % r)
plt.scatter(x, y, c=z)
plt.xlabel('x')
plt.ylabel('y')
plt.title('y as a function of x')
cbar = plt.colorbar()
plt.show()
英文:
from scipy.interpolate import LinearNDInterpolator
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1,1,5,6])
y = np.array([1,5,5,5])
z=[2,6,10,11]
points = np.array(list(zip(x,y)))
values = np.array(z)
i=2
j=4.5
Linear = LinearNDInterpolator(points, values)
r = Linear(i,j)
print("Linear %s" %r)
plt.scatter(x, y,c=z)
plt.xlabel('x')
plt.ylabel('y')
plt.title('y as a function of x')
cbar = plt.colorbar()
plt.show()
#This is a very simple code. But I want to know how LinearNDInterpolator is really working? And is the idea similar in 3d?
答案1
得分: 2
我们可以在文档中看到这是一个分段线性插值器
。您可以在这里找到有关它的介绍。
此外:
插值器是通过使用Qhull对输入数据进行三角剖分,并在每个三角形上执行线性重心插值来构建的。
英文:
We can see in the documentation that this is a Piecewise linear interpolant
. You can find a presentation of that here.
Also:
> The interpolant is constructed by triangulating the input data with Qhull, and on each triangle performing linear barycentric interpolation.
About Qhull. And you can find an article about linear barycentric interpolation here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论