We propose $\frac{|x-y|}{1+|y|}$, termed the ``P1 error" or ``plus-1 error", as a metric of errors. It equals half the harmonic mean of absolute error and relative error, effectively combining their advantages while mitigating their limitations. The P1 error approaches absolute error when $|y|$ is small, and approaches relative error when $|y|$ is large. An $\epsilon$ P1 error indicates that $x$ is close to $y$ at a tolerance level of $\epsilon$, in compliance with the ``isclose" definition used in popular numerical libraries.
翻译:我们提出$\frac{|x-y|}{1+|y|}$,称为“P1误差”或“加1误差”,作为一种误差度量。该度量等于绝对误差与相对误差的调和平均数的一半,有效结合了两者的优势,同时减轻了各自的局限性。当$|y|$较小时,P1误差趋近于绝对误差;当$|y|$较大时,则趋近于相对误差。一个$\epsilon$的P1误差表明$x$与$y$的接近程度满足容差水平$\epsilon$,这与主流数值库中使用的“isclose”定义一致。