Reference · Statistics

stats.normal_cdf

signature
stats.normal_cdf(num, num=, num=) -> float

What 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))
output
0.50.9750021048517796 0.0249978951482204280.97724986805182080.9500042097035593

Edge cases

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))
output
0.5 0.0 1.00.300000000000000040.5

Errors

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.

this one fails
print(stats.normal_cdf(0, 0, -1))
output
line 1: `stats.normal_cdf`: sigma must be positive, got -1
this one fails
print(stats.normal_cdf())
output
line 1: `stats.normal_cdf` expects a number as argument 1, got nothing

Chaining

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))
output
0.84130.9770.023

See also

stats.normal_inv, stats.normal_pdf, math.erf, stats.zscore

Thread
7Useful? Like it, or add to its thread below.

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