Reference · Math
math.erfc
math.erfc(num) -> floatWhat it does
The complementary error function, 1 - erf(x), as Python's math.erfc, computed so
that the small values in the tail keep their digits: 1 - math.erf(5) has lost most
of them to cancellation, math.erfc(5) has not. It runs from 2 at minus infinity to
0 at plus infinity.
Examples
print(math.erfc(0), math.erfc(1), math.erfc(-1))print(math.erfc(5), 1 - math.erf(5))print(math.erf(0.5) + math.erfc(0.5))1.0 0.15729920705028513 1.8427007929497150.0000000000015374597944280351 0.00000000000153743684450091681.0Edge cases
math.erfc(-x)is2 - math.erfc(x).- The tail underflows to
0.0aroundx = 27:math.erfc(28)is0.0. - Infinity gives
0.0, minus infinity2.0; NaN stays NaN. Neither is an error.
print(math.erfc(2), math.erfc(28))print(math.erfc(float("inf")), math.erfc(float("-inf")), math.erfc(float("nan")))0.004677734981047265 0.00.0 2.0 NaNErrors
An argument that is not a number is a runtime error, not an error value. There is no domain error: every number has an answer.
print(math.erfc(null))line 1: `math.erfc` expects a number as argument 1, got nullChaining
In a pipeline the number comes first. A two-sided p-value from a z-score:
print(1 | math.erfc)let z = 1.96print(math.fabs(z) / math.sqrt(2) | math.erfc | round(3))0.157299207050285130.05See also
math.erf, stats.normal_cdf, math.exp
Thread 0 posts
On math.erfc(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo