簡體   English   中英

從scipy python使用interp2d推斷

[英]Extrapolate using interp2d from scipy python

我正在嘗試使用scipy包進行2d推斷:

interp2d(df['maturity'], df['strike'], df['IV'], fill_value='extrapolate')(0.08, 0.65)

df ['maturity']的最小值為0.09,出現以下錯誤:

    IV = interp2d(group['maturity'], group['strike'], group['IV'], fill_value='extrapolate')(0.08, 0.65)
  File "C:\Anaconda2\lib\site-packages\scipy\interpolate\interpolate.py", line 298, in __call__
    z[:, out_of_bounds_x] = self.fill_value
ValueError: could not convert string to float: extrapolate

fill_value ='extrapolate'可以在interp1d上完美工作...如果有一種簡便的方法可以在2d方法上進行推斷,您知道嗎?

謝謝。

看起來我沒有做家庭作業。

fill_value = 'extrapolate'

僅適用於interp1d。 如果不給interp2d一個fill_value參數,它將推斷。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM