LinearNDinterpolator是如何真正工作的?它背后的理论是什么?

huangapple go评论69阅读模式
英文:

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对输入数据进行三角剖分,并在每个三角形上执行线性重心插值来构建的。

关于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.

huangapple
  • 本文由 发表于 2023年2月9日 02:19:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390126.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定