Contents
(Evaluated via standard normal integration)
Deep Breakdown
What it tells me (Situation Awareness): is the CDF of the standard normal distribution — it has no closed form but is tabulated and available in all statistical software. For any Normal(), probabilities are computed by standardizing: . This is the most-used single function in classical statistics.
Flowchart
Real-world use
Where it is used
Computing z-test p-values, confidence interval bounds, probability of exceeding a threshold, and any Normal probability query. Foundation of hypothesis testing and quality control (Six Sigma).
Problem it solves
Converts a Normal probability query into a table lookup or scipy call — the integral has no closed form but is well-approximated.
How it solves the problem
Uses precomputed tables or approximations like the error function: .
Example in a business
Z-test for A/B conversion rates: compute z-statistic, then for two-tailed test. If , reject null.
The formula, piece by piece
where
- No algebraic closed form.
- In terms of error function: .
- Quantile (inverse): =
norm.ppf(p)in Python.
The formula in words
" is the probability that a standard normal random variable is at or below ." Key values: , , .
Critical Concepts
- (symmetry of standard normal).
- 95% CI uses .
- Python:
from scipy.stats import norm; norm.cdf(z). - R:
pnorm(z).
Step-by-step calculation (tiny example)
Step 1: Revenue ~N(10000, 2000²), query P(Revenue < 13000)
Step 2: Standardize
Step 3: Lookup
Step 4: Interpret 93.3% of days have revenue below $13,000.
Code examples
Beginner example (Python)
from scipy.stats import norm
mu, sigma = 10_000, 2_000
x_threshold = 13_000
z = (x_threshold - mu) / sigma
p_below = norm.cdf(z)
print(f"Z = {z:.2f}")
print(f"P(revenue < {x_threshold:,}) = {p_below:.4f} ({p_below*100:.1f}%)")Beginner example (R)
mu <- 10000; sigma <- 2000; x_threshold <- 13000
z <- (x_threshold - mu) / sigma
p_below <- pnorm(z)
cat(sprintf("Z = %.2f | P(X < %d) = %.4f\n", z, x_threshold, p_below))Professional example (Python)
import numpy as np
from scipy.stats import norm
def z_test_two_proportion( conversions_a: int, n_a: int, conversions_b: int, n_b: int, alpha: float = 0.05 ) -> dict[str, float | bool]:
"""Two-proportion z-test for A/B conversion rate comparison. Uses Φ(Z) for p-value computation. Args: conversions_a: Number of conversions in control. n_a: Total users in control. conversions_b: Number of conversions in treatment. n_b: Total users in treatment. alpha: Significance level. Returns: Dict with z-statistic, p-value, and decision. """
p_a = conversions_a / n_a
p_b = conversions_b / n_b
p_pooled = (conversions_a + conversions_b) / (n_a + n_b)
se_pooled = np.sqrt(p_pooled * (1 - p_pooled) * (1/n_a + 1/n_b))
z_stat = (p_b - p_a) / se_pooled
p_value = 2 * (1 - norm.cdf(abs(z_stat)))
return { "p_a": p_a, "p_b": p_b, "z_stat": z_stat, "p_value": p_value, "significant": p_value < alpha, "relative_lift": (p_b - p_a) / p_a, }
result = z_test_two_proportion(100, 2000, 130, 2000)
print("A/B Test Z-test result:")
for key, val in result.items():
print(f" {key}: {round(val, 4) if isinstance(val, float) else val}")Source: domain knowledge