Lesson 5 of 18
Normal Distribution
The Bell Curve
The normal distribution is the most important distribution in statistics. It is symmetric around the mean and fully described by two parameters: mean and standard deviation . We write .
The probability density function is:
ight)$$ ```python import math def normal_cdf(x, mu=0, sigma=1): return 0.5 * (1 + math.erf((x - mu) / (sigma * math.sqrt(2)))) def normal_pdf(x, mu=0, sigma=1): return (1 / (sigma * math.sqrt(2 * math.pi))) * math.exp(-0.5 * ((x - mu) / sigma) ** 2) # Standard normal: mu=0, sigma=1 print(normal_cdf(0)) # 0.5 print(round(normal_pdf(0), 4)) # 0.3989 ``` ### CDF vs PDF - **PDF** (probability density function): the height of the curve at $x$. Not a probability itself. - **CDF** (cumulative distribution function): $P(X leq x)$. This IS a probability (0 to 1). ### The 68-95-99.7 Rule For a normal distribution $mathcal{N}(mu, sigma^2)$: - $P(mu - sigma leq X leq mu + sigma) approx$ **68%** - $P(mu - 2sigma leq X leq mu + 2sigma) approx$ **95%** - $P(mu - 3sigma leq X leq mu + 3sigma) approx$ **99.7%** ### Your Task Implement `normal_stats(mu, sigma, x)` that prints: 1. `CDF(x)` — the probability that $X leq x$ (rounded to 4 decimal places) 2. `PDF(x)` — the density at $x$ (rounded to 4 decimal places)Pyodide loading...
Loading...
Click "Run" to execute your code.