File:Interpolation trois types.svg

Summary

Description
Français : Trois procédés d'interpolation avec Python : scipy.interpolate.interp1d(kind="nearest"), numpy.interp() et scipy.interpolate.KroghInterpolator().
English: Three ways to interpolate with Python: scipy.interpolate.interp1d(kind="nearest"), numpy.interp() and scipy.interpolate.KroghInterpolator().
Date
Source Own work
Author Cdang
Category:Files by User:cdang
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt

xp = np.linspace(0, 2*np.pi, 6)
yp = np.sin(xp)

x = np.linspace(0, 2*np.pi, 101)

# constante

finterpa = interpolate.interp1d(xp, yp, kind="nearest",
  fill_value="extrapolate")

ya = finterpa(x)

# linéaire

yb = np.interp(x, xp, yp)

# polynomiale

finterpc = interpolate.KroghInterpolator(xp, yp)

yc = finterpc.__call__(x)

# tracé

fig.suptitle("Interpolation")

# plt.plot(x, np.sin(x), ":k", label="sinus")
plt.plot(x, ya, label="constante")
plt.plot(x, yb, label="linéaire")
plt.plot(x, yc, label="polynomiale")
plt.plot(xp, yp, "r+")

plt.legend()

plt.savefig("interpolation_trois_types.svg", format="svg")

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Interpolation%20trois%20types.svgCategory:Self-published work
Category:Interpolation
Category:CC-BY-SA-4.0 Category:Files by User:cdang Category:Interpolation Category:Self-published work Category:Valid SVG created with Matplotlib