This package provides functionality for bilinear interpolation. The current capabilities are the following:
-
Computation of an interpolant function based on the least sqares method.
-
The interpolant is a bilinear polynomial.
-
The degree of the polynomial is chosen automatically so that it would provide a perfect fit for given set of coordinates.
-
-
Visualisation of the bivariate function.
-
Mathematical representation of the interpolant polynomial.
pip install simple-interpolator
Find out more here.
The library simple_interpolator
provides a file interpolator
encapsulating a class Interpolator
.
from simple_interpolator.interpolator import Interpolator
members | desription |
---|---|
graph() |
three-dimentional graph of the interpolant |
colormap() |
two-dimentional colormap of the interpolant |
show() |
renders all of the visualisations |
add_coordinate() |
provide an additional coordiante |
add_coordinates() |
provide a list of additional coordinates |
set_rank() |
set a max power of a variable |
auto_rank() |
fit the data perfectly automatically |
data |
a list of the provided coordinates |
f |
an interpolant function |
print_f() |
mathematical representation of the interpolant |
from simple_interpolator.interpolator import Interpolator
i = Interpolator([(2,-5,2),(6,-3,4),(3,-6,4),(-4,3,5),(5,-4,8),(3,7,-5)])
print("Provided coordinates:\n\n\t", i.data, "\n")
print("An interpolant:\n\n",end='\t')
i.print_f(1)
i.graph()
i.colormap()
i.show()
Output:
Provided coordinates:
[(2, 5, -4), (6, 3, -4), (3, -6, 4), (4, -3, 5), (5, -4, 8)]
Generated interpolant:
9.7+1.5x+0.4x²-0.1y-0.1xy-0.1x²y+0.2y²
The spacial visualisation is provided as a rotatable 3D object. The picture presented here is just an illustration.