Numpy 的 spacing(~)
方法返回下一個可表示的相鄰數字之間的差異。
參數
1. a
| array-like
輸入數組。
2. out
| Numpy array
| optional
您可以將計算結果放入 out 指定的數組中,而不是創建新數組。
3. where
| boolean
的array
| optional
標記為 False 的值將被忽略,即它們的原始值將未被初始化。如果指定了 out 參數,行為會略有不同 - 原始值將保持不變。由於這讓許多人感到困惑,請查看下麵的示例。
返回值
如果 a
是標量,則返回標量。否則,返回一個浮點數的 Numpy 數組。
例子
這是一個例子:
5 + np.spacing(5)
5.000000000000001
在這裏,Numpy 中可以表示的下一個最小數字就是輸出中顯示的數字。
相關用法
- Python scipy spatial.KDTree用法及代碼示例
- Python scipy spatial.Delaunay.transform用法及代碼示例
- Python scipy spatial.distance.wminkowski用法及代碼示例
- Python string splitlines()用法及代碼示例
- Python string split()用法及代碼示例
- Python NumPy splitlines方法用法及代碼示例
- Python numpy string splitlines()用法及代碼示例
- Python NumPy split方法用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python NumPy squeeze方法用法及代碼示例
- Python scipy.ndimage.binary_opening用法及代碼示例
- Python scipy.signal.windows.tukey用法及代碼示例
- Python scipy.stats.mood用法及代碼示例
- Python str.isidentifier用法及代碼示例
- Python sklearn.metrics.fbeta_score用法及代碼示例
- Python scipy.fft.ihfftn用法及代碼示例
- Python scipy.stats.normaltest用法及代碼示例
- Python scipy.ndimage.convolve1d用法及代碼示例
- Python scipy.stats.arcsine用法及代碼示例
- Python scipy.interpolate.UnivariateSpline.antiderivative用法及代碼示例
- Python NumPy sign方法用法及代碼示例
- Python scipy.linalg.hadamard用法及代碼示例
- Python socket.create_server用法及代碼示例
- Python sklearn.linear_model.PassiveAggressiveRegressor用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | spacing method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。