Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A slight mismatch in the results compared to scipy? #6

Open
ysBach opened this issue Jan 14, 2023 · 0 comments
Open

A slight mismatch in the results compared to scipy? #6

ysBach opened this issue Jan 14, 2023 · 0 comments

Comments

@ysBach
Copy link

ysBach commented Jan 14, 2023

I found this repo very useful and tried it to see if I can completely replace some interpolation that I used for my package.

While testing, I found a slight mismatch with scipy:

from fast_interp import interp1d, interp2d
from scipy import interpolate as si
import numpy as np

npt = 15
xvals, dx = np.linspace(0, 2*np.pi, npt, retstep=True)
yvals = np.exp(xvals)*np.exp(np.sin(xvals))*np.cos(xvals/4)
interpolater = interp1d(xvals.min(), xvals.max(), dx, yvals, k=3, p=False)
scipy_interp = si.interp1d(xvals, yvals, kind="cubic")

fig, axs = plt.subplots(2, 1, figsize=(8, 5), sharex=False, sharey=False, gridspec_kw={"height_ratios": [3, 1] })

xx = np.linspace(0, 2*np.pi, 1000)
axs[0].plot(xvals, yvals, "o")
axs[0].plot(xx, interpolater(xx), lw=0.5, label="fast_interp")
axs[0].plot(xx, scipy_interp(xx), lw=0.5, label="scipy interp1d")
axs[1].plot(xx, scipy_interp(xx) - interpolater(xx))
axs[0].legend()
axs[1].set(title = "difference (scipy's interp1d - fast_interp)")
plt.tight_layout()
plt.show();

image

Maybe I am missing something or found a bug??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant