码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • numpy.isclose


    参考  numpy.isclose - 云+社区 - 腾讯云

    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

    allclose

    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

    1. >>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
    2. array([ True, False])
    3. >>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
    4. array([ True, True])
    5. >>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
    6. array([False, True])
    7. >>> np.isclose([1.0, np.nan], [1.0, np.nan])
    8. array([ True, False])
    9. >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
    10. array([ True, True])
    11. >>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
    12. array([ True, False])
    13. >>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
    14. array([False, False])
    15. >>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
    16. array([ True, True])
    17. >>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
    18. array([False, True])

  • 相关阅读:
    建议收藏【整合】基于经典全连接神经网络的(cat、dog、panda分类)【步骤完备、图形完整】
    【PCIE709-F】基于复旦微JFM7VX690T80 FPGA的全国产化8通道光纤双FMC接口数据处理平台
    【IO多路转接】poll&epoll
    git工作中常用的命令
    银河麒麟Telnet远程登录
    暑期留校——区间DP-板子题石子合并
    不会吧,都2023年了你还不会JavaStream?
    NX二次开发-UFUN创建角度尺寸标注UF_DRF_create_angular_dim
    一起Talk Android吧(第四百一十七回:解决Glide不能加载网络图片的方法)
    JVM在哪里?
  • 原文地址:https://blog.csdn.net/weixin_36670529/article/details/102457192
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号