liveBook · Manning

Scipy.stats.norm.cdf

As explained in Statistics Every Programmer Needs

scipy.stats.norm.cdf is a SciPy function that evaluates the cumulative distribution function of a normal distribution at specified values.

scipy.stats.norm.cdf evaluates the cumulative probability, or area under a normal-distribution curve, up to a supplied value. For a standardized score z, it returns the probability that a normally distributed value is less than or equal to z. section 3.1.1

The function is useful when a normal-model result must become a percentile, threshold probability, or decision estimate. Standardize a raw value first with z = (value − mean) / standard deviation, then pass z to norm.cdf(). section 13.4 section 3.1.1

Estimate completion by a deadline

For a project with a mean duration of 29 weeks, a standard deviation of 1.41 weeks, and a 30-week deadline: z_score = (30 - 29) / 1.41; probability = stats.norm.cdf(z_score). The resulting z-score is 0.709 and SciPy returns 0.7609, or a 76.09% estimated chance of finishing within 30 weeks. section 13.4

Calculate a probability range

Compute two cumulative probabilities and subtract them: norm.cdf(1.5) - norm.cdf(1.0) = 0.091848..., giving roughly a 9.18% probability between 1.0 and 1.5 standard deviations above the mean. section 3.1.1

>>> import scipy.stats as stats
>>> due_date = 30
>>> mean = 29
>>> standard_deviation = 1.41
>>> z_score = (due_date - mean) / standard_deviation

>>> probability = stats.norm.cdf(z_score)

>>> print(f'z-score: {z_score:.3f}')
    z-score: 0.709

>>> print(f'Probability of completing the project within '
>>>       f'{due_date} weeks: {probability:.2%}')
    Probability of completing the project within 30 weeks: 76.09%

Inspect the complete Python calculation, including imports, standardization, formatted output, and the 76.09% result. section 13.4

Figure 13.5 Normal probability distribution of project completion time, where the mean duration is 29 weeks and the standard deviation is 1.41 weeks. The due date of 30 weeks is marked, showing a 78.5% probability (using the z-table results) of completing the project within this timeframe.
figure

Use the normal-distribution visualization to relate the cumulative area through the deadline to the modeled completion probability. section 13.4

How Statistics Every Programmer Needs covers it

How deep it goes
Explains standardization and cumulative-area subtraction with Python examples, but does not develop the normal-distribution derivation.
Examples
Demonstrates one-standard-deviation percentiles, the 1.0-to-1.5 interval, and a 30-week project deadline.
What it assumes
Assumes familiarity with means, standard deviations, z-scores, and normal distributions while demonstrating cumulative probability from zero.
What you can do after
Apply it via SciPy to convert standardized values into cumulative probabilities and differences between probability bounds.
How it connects
Connects z-scores, standard normal distributions, percentiles, probability intervals, and project completion estimates.

Also explained in

Compare how 2 books explain scipy.stats.norm.cdf →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.