代码之家  ›  专栏  ›  技术社区  ›  Jürg Merlin Spaak

微分scipy.interpolate.interp1d

  •  0
  • Jürg Merlin Spaak  · 技术社区  · 6 年前

    给定一个两个向量 x y scipy.interpolate.interp1d 计算(二次)样条曲线。但是我对样条曲线本身不感兴趣,而是对样条曲线的导数感兴趣。

    但是我找不到多项式参数存储在哪里 interp1d 我试过了 interp1d.__dict__ ,其中包含 interp1d._spline

    1 回复  |  直到 6 年前
        1
  •  2
  •   Tarifazo    6 年前

    InterpolatedUnivariateSpline ,它有 derivative method

    from scipy.interpolate import InterpolatedUnivariateSpline as IUS
    import numpy as np
    import matplotlib.pyplot as plt
    
    x = np.arange(10)
    y = x**2 + np.random.normal(size=10)
    
    u = IUS(x,y)
    u_der = u.derivative()
    
    plt.plot(x, y, 'go')
    plt.plot(x, u(x), 'b--')
    plt.plot(x, u_der(x), 'k')