Как делать интерполяцию в конденсированное облако точек

сердечный привет, присутствующее сообщение - это, чтобы спрашивать, как я могу реализовывать spline или полиномиальную интерполяцию с каким-то из книжных магазинов python, так как она, попробовав делать с многочленом Лагранжа книжного магазина scipy, он появляется у меня, что он не способен обрабатывать вышеупомянутые точки, (sake naan) далее присоединенный вышеупомянутый код:

import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import lagrange

xd=[0,1.3,2.7,3.8,4.5,5.7,6.4,7.4,8,9,10.5,10.5,10.6,11.1,12.1,13.2,14.2,15.2,15.8,16.6,17.3,17.7,17.8,20.2,20.4,22,22.3,22.5,22.7,23,23.6,23.7,23.9,24.1,  24.5,25.84,27.2,27.4,27.5,27.7,28.2,28.3,28.6,28.7,28.8,30.7,32.4,32.5,32.8,32.9,33.2,33.2,33.5,33.6,34.5,34.7,34.8,35.15,35.4,35.5,35.6,37.1,37.2,37.6,37.6,37.6,38,38.4,38.4,38.7,39.4,39.6,41.3,44.1,44.4,44.5,44.8,44.9,44.9,45.9,46.1,46.4,46.5,46.5,  46.6,46.9,  47,47.1,47.3,47.5,47.7,47.9,48,48.1,48.4,48.5,48.5,48.9,49.1,49.3,49.3,49.6,49.7,50.1,50.1,50.1,50.2,50.5,50.6,50.8,50.9,51.7,51.7,52,52.1,52.2,52.3,52.6,53.7,53.8,53.8,54.2,54.3,54.5,54.6,54.8,54.9,]
yd=[2184.77,2184.47,2184.23,2184.02,2183.83,2183.53,2183.33,2182.97,2182.76,2182.28,2181.52,2181.51,2181.51,2181.28,2180.85,2180.48,2180.15,2179.84,2179.7  ,2179.54,2179.42,2179.37,2179.36,2179.18,2179.16,2178.9,2178.88,2178.86,2178.86,2178.84,2178.79,2178.75,2178.71,2178.66,2178.54,2178.08,2177.62,2177.57,2177.53,2177.48,2177.4,2177.39,2177.38,2177.38,2177.38,2177.39,2177.34,2177.34,2177.34,2177.35,2177.37,2177.38,2177.41,2177.43,2177.71,2177.81,2177.862,2178.05,2178.17,2178.22,2178.25,2179.01,2179.07,2179.26,2179.28,2179.29,2179.5,2179.7,2179.73,2179.87,2180.21,2180.32,2181.13,2182.44,2182.57,2182.6,2182.69,2182.71,2182.72,2182.87,2182.91,2183.01,2183.03,2183.04,2183.07,2183.17,2183.2,2183.26,2183.33,2183.4,2183.48,2183.52,2183.57,2183.61,2183.71,2183.75,2183.76,2183.9,2183.96,2184.08,2184.09,2184.22,2184.28,2184.42,2184.43,2184.44   ,2184.47,2184.62,2184.66,2184.75,2184.82,2185.22,2185.26,2185.38,2185.45,2185.47,2185.5,2185.6,2185.89,2185.9,2185.92,2186.05,2186.08,2186.13,2186.17,2186.23,2186.23]  

ywater=2182
n=10
z=ywater-np.min(yd)
deltazi=z/n
xmin=np.min(xd)
xmax= np.max(xd)
ymin=np.min(yd)
poly = lagrange(xd, yd)

ywater=2182
n=10
z=ywater-np.min(yd)
deltazi=z/n
xmin=np.min(xd)
xmax= np.max(xd)
ymin=np.min(yd)
poly = lagrange(xd, yd)

print(poly)

plt.plot(xd,yd, '+',color='green')
plt.plot(xd,poly(xd), '+',color='green')
plt.axhline(ywater)
plt.show()

Я благодарен за Вашу помощь, если они знают другого метода или лучшей оптимальной формы, чтобы это разрабатывать.

0
задан 17.09.2019, 00:55
1 ответ

я надеюсь, что он стоит это тебе.

import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
xd=[0,1.3,2.7,3.8,4.5,5.7,6.4,7.4,8,9,10.5,10.5,10.6,11.1,12.1,13.2,14.2,15.2,15.8,16.6,17.3,17.7,17.8,20.2,20.4,22,22.3,22.5,22.7,23,23.6,23.7,23.9,24.1,  24.5,25.84,27.2,27.4,27.5,27.7,28.2,28.3,28.6,28.7,28.8,30.7,32.4,32.5,32.8,32.9,33.2,33.2,33.5,33.6,34.5,34.7,34.8,35.15,35.4,35.5,35.6,37.1,37.2,37.6,37.6,37.6,38,38.4,38.4,38.7,39.4,39.6,41.3,44.1,44.4,44.5,44.8,44.9,44.9,45.9,46.1,46.4,46.5,46.5,  46.6,46.9,  47,47.1,47.3,47.5,47.7,47.9,48,48.1,48.4,48.5,48.5,48.9,49.1,49.3,49.3,49.6,49.7,50.1,50.1,50.1,50.2,50.5,50.6,50.8,50.9,51.7,51.7,52,52.1,52.2,52.3,52.6,53.7,53.8,53.8,54.2,54.3,54.5,54.6,54.8,54.9,]
yd=[2184.77,2184.47,2184.23,2184.02,2183.83,2183.53,2183.33,2182.97,2182.76,2182.28,2181.52,2181.51,2181.51,2181.28,2180.85,2180.48,2180.15,2179.84,2179.7  ,2179.54,2179.42,2179.37,2179.36,2179.18,2179.16,2178.9,2178.88,2178.86,2178.86,2178.84,2178.79,2178.75,2178.71,2178.66,2178.54,2178.08,2177.62,2177.57,2177.53,2177.48,2177.4,2177.39,2177.38,2177.38,2177.38,2177.39,2177.34,2177.34,2177.34,2177.35,2177.37,2177.38,2177.41,2177.43,2177.71,2177.81,2177.862,2178.05,2178.17,2178.22,2178.25,2179.01,2179.07,2179.26,2179.28,2179.29,2179.5,2179.7,2179.73,2179.87,2180.21,2180.32,2181.13,2182.44,2182.57,2182.6,2182.69,2182.71,2182.72,2182.87,2182.91,2183.01,2183.03,2183.04,2183.07,2183.17,2183.2,2183.26,2183.33,2183.4,2183.48,2183.52,2183.57,2183.61,2183.71,2183.75,2183.76,2183.9,2183.96,2184.08,2184.09,2184.22,2184.28,2184.42,2184.43,2184.44   ,2184.47,2184.62,2184.66,2184.75,2184.82,2185.22,2185.26,2185.38,2185.45,2185.47,2185.5,2185.6,2185.89,2185.9,2185.92,2186.05,2186.08,2186.13,2186.17,2186.23,2186.23]  
d = {'x' : xd,'y' : yd} #creo diccionario
f=pd.DataFrame(d)  #creo dataset
sns.regplot(x="x", y="y", data=f,order=2); # cambia order dependiendo del grado del polinomio que quieras
plt.show()
0
ответ дан 01.12.2019, 16:46