Reference · Statistics
stats.normal_cdf
stats.normal_cdf(num, num=, num=) -> floatWhat it does
The cumulative probability of a normal distribution at x: the share of the
distribution that lies at or below x, from 0 to 1, as Python's
NormalDist(mu, sigma).cdf(x). The mean mu is 0 and the standard deviation
sigma 1 by default, the standard normal. The probability of a range is the
difference of two of them.
Examples
print(stats.normal_cdf(0))print(stats.normal_cdf(1.96), stats.normal_cdf(-1.96))print(stats.normal_cdf(130, 100, 15))print(stats.normal_cdf(1.96) - stats.normal_cdf(-1.96))0.50.9750021048517796 0.0249978951482204280.97724986805182080.9500042097035593Edge cases
- At
muit is exactly0.5. - Far below the mean it is
0.0and far above1.0; the float runs out of digits. - It is the inverse of stats.normal_inv, up to the last digit.
nullformuorsigmameans the default.
print(stats.normal_cdf(7, 7, 3), stats.normal_cdf(-50), stats.normal_cdf(50))print(stats.normal_cdf(stats.normal_inv(0.3)))print(stats.normal_cdf(0, null, 2))0.5 0.0 1.00.300000000000000040.5Errors
A sigma of zero or below is a runtime error, not an error value. So is an
argument that is not a number, or a missing x.
print(stats.normal_cdf(0, 0, -1))line 1: `stats.normal_cdf`: sigma must be positive, got -1print(stats.normal_cdf())line 1: `stats.normal_cdf` expects a number as argument 1, got nothingChaining
In a pipeline x comes first and mu and sigma are the arguments:
print(1 | stats.normal_cdf | round(4))print(130 | stats.normal_cdf(100, 15) | round(3))print(1 - (130 | stats.normal_cdf(100, 15)) | round(3))0.84130.9770.023See also
stats.normal_inv, stats.normal_pdf, math.erf, stats.zscore
Thread 0 posts
On stats.normal_cdf(): 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