【问题标题】:wrong interpolation in scipy.interpolate.interp1dscipy.interpolate.interp1d 中的错误插值
【发布时间】:2021-10-03 14:03:47
【问题描述】:

我对 scipy.interpolate.interp1d 有疑问

df = 
ang frc
-40 -15605.47
-30 -16051.253
-20 -10895.4
-10 -6205.733
0   -1730.65
10  2697.85
20  7217.59
30  12022.48
40  17298.647
import pandas as pd
from scipy.interpolate import interp1d

df = pd.read_csv('111.txt', sep='\t')
print(df)
interpi = interp1d(df['frc'], df['ang'], fill_value='extrapolate')
print(interpi(-17000))

它提供 import pandas as pd 从 scipy.interpolate 导入 interp1d

df = pd.read_csv('111.txt', sep='\t') 打印(df) interpi = interp1d(df['frc'], df['ang'], fill_value='extrapolate') 打印(interpi(-17000))


It gives -8.717 which is clearly wrong!
I rather it gives Error

can anyone help?

【问题讨论】:

    标签: python pandas dataframe scipy


    【解决方案1】:

    我认为这取决于您对“错误”的定义。 从插值器(或更确切地说是外插器)的角度来看这个问题: 如果x_new = - 17000,即超出范围,则使用以下点(下图中的蓝色)进行推断:(-15605.47, -40)(-16051.253, -30)。从这些数据中,插值器得知 frc 的减少会导致 ang 的增加。见下图。我为可见性裁剪了插值范围。

    【讨论】:

    • 感谢您的帮助,但我仍然感到困惑。
    • A.为什么插值器不检查自己。 B. 我该如何解决?
    猜你喜欢
    • 2013-09-10
    • 1970-01-01
    • 1970-01-01
    • 2017-02-05
    • 2013-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多