numpy isclose 函数是否返回错误答案? [英] is numpy isclose function returning bad answer?

查看:72
本文介绍了numpy isclose 函数是否返回错误答案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下示例中使用 numpy isclose:

Using numpy isclose in the following example:

import numpy as np
np.isclose(1533761040,1533748023.0, atol=1)

返回 True,这是 False.

Returns True, which is False.

推荐答案

根据文档,isclose() 使用这个公式:

According to the documentation, isclose() uses this formula:

absolute(a - b) <= (atol + rtol * absolute(b))

rtol 默认为 1e-05,并且您为 atol 提供了 1 的值,因此结果为:

rtol defaults to 1e-05, and you supplied a value of 1 for atol, so this works out to:

13017.0 <= 15338.48023

这是真的.为什么你认为它是假的?

Which is true. Why did you expect it to be false?

这篇关于numpy isclose 函数是否返回错误答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆