当前位置:网站首页>numpy.isclose
numpy.isclose
2022-08-01 23:21:00 【Wanderer001】
numpy.isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)[source]
Returns a boolean array where two arrays are element-wise equal within a tolerance.
The tolerance values are positive, typically very small numbers. The relative difference (rtol * abs(b)) and the absolute difference atol are added together to compare against the absolute difference between a and b.
Warning:The default atol is not appropriate for comparing numbers that are much smaller than one (see Notes).
Parameters:
a, b:array_like
Input arrays to compare.
rtol:float
The relative tolerance parameter (see Notes).
atol:float
The absolute tolerance parameter (see Notes).
equal_nan:bool
Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to NaN’s in b in the output array.
Returns
y:array_like
Returns a boolean array of where a and b are equal within the given tolerance. If both a and b are scalars, returns a single boolean value.
See also
Notes
New in version 1.7.0.
For finite values, isclose uses the following equation to test whether two floating point values are equivalent.
absolute(a - b) <= (atol + rtol * absolute(b))
Unlike the built-in math.isclose, the above equation is not symmetric in a and b – it assumes b is the reference value – so that isclose(a, b) might be different from isclose(b, a). Furthermore, the default value of atol is not zero, and is used to determine what small values should be considered close to zero. The default value is appropriate for expected values of order unity: if the expected values are significantly smaller than one, it can result in false positives. atol should be carefully selected for the use case at hand. A zero value for atol will result in False if either a or b is zero.
Examples
>>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
array([ True, False])
>>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
array([ True, True])
>>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
array([False, True])
>>> np.isclose([1.0, np.nan], [1.0, np.nan])
array([ True, False])
>>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
array([ True, True])
>>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
array([ True, False])
>>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
array([False, False])
>>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
array([ True, True])
>>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
array([False, True])边栏推荐
猜你喜欢

简单3D渲染器的制作

Codeforces CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) A-D 题解

y84.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十五)

What is CICD excuse me

华为无线设备配置双链路冷备份(AP指定配置方式)

访问控制台中的选定节点

From 0 to 1: Design and R&D Notes of Graphic Voting Mini Program

解决yolov5训练时出现:“AssertionError: train: No labels in VOCData/dataSet_path/train.cache. Can not train ”

研发团队数字化转型实践

npm包【详解】(内含npm包的开发、发布、安装、更新、搜索、卸载、查看、版本号更新规则、package.json详解等)
随机推荐
How to better understand and do a good job?
问题解决方式了
qt-faststart installation and use
【C语言进阶】文件操作(二)
还在纠结报表工具的选型么?来看看这个
[LeetCode304 Weekly Competition] Two questions about the base ring tree 6134. Find the closest node to the given two nodes, 6135. The longest cycle in the graph
Access the selected node in the console
仿牛客网项目第三章:开发社区核心功能(详细步骤和思路)
Chapter 11 Working with Dates and Times
How to use pywinauto and pyautogui to link the anime lady and sister please go home
Always use "noopener" or "noreferrer" for links that open in a new tab
如何更好的理解的和做好工作?
计算两点之间的中点
excel change cell size
D - Linear Probing- 并查集
下载安装 vscode(含汉化、插件的推荐和安装)
从0到100:招生报名小程序开发笔记
分享10套开源免费的高品质源码,免费源码下载平台
6132. All the elements in the array is equal to zero - quick sort method
Chapter 11 Working with Dates and Times