当前位置:网站首页>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])边栏推荐
猜你喜欢

美赞臣EDI 940仓库装运订单详解

What is CICD excuse me

数据分析04

chrome copies the base64 data of an image

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

程序员如何优雅地解决线上问题?

伸展树的特性及实现

System availability: 3 9s, 4 9s in SRE's mouth... What is it?
![[LeetCode304周赛] 两道关于基环树的题 6134. 找到离给定两个节点最近的节点,6135. 图中的最长环](/img/63/16de443caf28644d79dc6e6889e5dd.png)
[LeetCode304周赛] 两道关于基环树的题 6134. 找到离给定两个节点最近的节点,6135. 图中的最长环

仿牛客网项目第三章:开发社区核心功能(详细步骤和思路)
随机推荐
杭电多校3 1012. Two Permutations dp*
excel edit a cell without double clicking
SQL Server(设计数据库--存储过程--触发器)
B. Difference Array--Codeforces Round #808 (Div. 1)
华为无线设备配置双链路冷备份(AP指定配置方式)
Codeforces CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) A-D 题解
6133. Maximum number of packets
从0到100:招生报名小程序开发笔记
excel vertical to horizontal
What is CICD excuse me
Create virtual environments with virtualenv and Virtualenvwrapper virtual environment management tools
visual studio code multiple editing
y84. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (15)
从0到1:图文投票小程序设计与研发笔记
测试岗月薪5-9k,如何实现涨薪到25k?
excel change cell size
leetcode刷题
颜色透明参数
如何使用pywinauto和pyautogui将动漫小姐姐链接请回家
drf生成序列化类代码