本文簡要介紹 python 語言中 scipy.misc.central_diff_weights
的用法。
用法:
scipy.misc.central_diff_weights(Np, ndiv=1)#
Np-point 中心導數的返回權重。
假設函數點等距。
如果權重在向量 w 中,則導數為 w[0] * f(x-ho*dx) + ... + w[-1] * f(x+h0*dx)
- Np: int
中心導數的點數。
- ndiv: 整數,可選
分區數。默認值為 1。
- w: ndarray
Np-point 中心導數的權重。其大小為 Np。
參數 ::
返回 ::
注意:
對於大量點可能不準確。
參考:
例子:
我們可以計算一個函數的導數值。
>>> from scipy.misc import central_diff_weights >>> def f(x): ... return 2 * x**2 + 3 >>> x = 3.0 # derivative point >>> h = 0.1 # differential step >>> Np = 3 # point number for central derivative >>> weights = central_diff_weights(Np) # weights for first derivative >>> vals = [f(x + (i - Np/2) * h) for i in range(Np)] >>> sum(w * v for (w, v) in zip(weights, vals))/h 11.79999999999998
這個值接近解析解:f'(x) = 4x,所以 f'(3) = 12
相關用法
- Python SciPy misc.ascent用法及代碼示例
- Python SciPy misc.derivative用法及代碼示例
- Python SciPy misc.face用法及代碼示例
- Python SciPy misc.electrocardiogram用法及代碼示例
- Python SciPy mstats.trim用法及代碼示例
- Python SciPy matlab.loadmat用法及代碼示例
- Python SciPy mstats.winsorize用法及代碼示例
- Python SciPy mstats.argstoarray用法及代碼示例
- Python SciPy matlab.savemat用法及代碼示例
- Python SciPy mstats.trima用法及代碼示例
- Python SciPy mstats.tmin用法及代碼示例
- Python SciPy mstats.tmax用法及代碼示例
- Python SciPy mstats.kruskalwallis用法及代碼示例
- Python SciPy mstats.sem用法及代碼示例
- Python SciPy mstats.zscore用法及代碼示例
- Python SciPy mstats.zmap用法及代碼示例
- Python SciPy mstats.mode用法及代碼示例
- Python SciPy mstats.hmean用法及代碼示例
- Python SciPy mstats.variation用法及代碼示例
- Python SciPy mstats.compare_medians_ms用法及代碼示例
- Python SciPy mstats.gmean用法及代碼示例
- Python SciPy mstats.pearsonr用法及代碼示例
- Python SciPy mstats.kruskal用法及代碼示例
- Python SciPy mstats.tmean用法及代碼示例
- Python SciPy mstats.mquantiles用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.misc.central_diff_weights。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。