Simple exemple sur comment calculer et tracer une extrapolation avec python et matplotlib (source):
[image:extrapolate]
from scipy.interpolate import InterpolatedUnivariateSpline
import matplotlib.pyplot as plt
import numpy as np
xi = np.array([0.2, 0.5, 0.7, 0.9])
yi = np.array([0.3, -0.1, 0.2, 0.1])
plt.figure()
plt.scatter(xi, yi)
x = np.linspace(0, 1.0, 50)
for order in range(1, 4):
s = InterpolatedUnivariateSpline(xi, yi, k=order)
y = s(x)
plt.plot(x, y)
plt.title("Extrapolation simple avec python")
plt.grid()
plt.show()
Recherches associées
Liens | Site |
---|---|
Extrapolation (mathématiques) | wikipedia |
How to make scipy.interpolate give an extrapolated result beyond the input range? | stackoverflow |
interpolate | doc scipy |
Is there easy way in python to extrapolate data points to the future? | stackoverflow |