Normal Distributions & Gaussian Mathematics
The Gaussian Normal Distribution models continuous random phenomena. Its Probability Density Function (PDF) is defined by mean $\mu$ and standard deviation $\sigma$, creating the classic bell curve 🔔.
import math
# Gaussian Probability Density Function (PDF):
def gaussian_pdf(x, mu=0.0, sigma=1.0):
coefficient = 1.0 / (sigma * math.sqrt(2 * math.pi))
exponent = math.exp(-0.5 * ((x - mu) / sigma) ** 2)
return coefficient * exponent
print(f"Peak density at x=0: {gaussian_pdf(0.0):.4f} 🔔") # 0.3989
print(f"Density at 1 std dev (x=1): {gaussian_pdf(1.0):.4f} 📉") # 0.2420
# 50. Normal Distributions & Gaussian Mathematics The Gaussian Normal Distribution models continuous random phenomena. Its Probability Density Function (PDF) is defined by mean $\mu$ and standard deviation $\sigma$, creating the classic bell curve 🔔. ```python import math # Gaussian Probability Density Function (PDF): def gaussian_pdf(x, mu=0.0, sigma=1.0): coefficient = 1.0 / (sigma * math.sqrt(2 * math.pi)) exponent = math.exp(-0.5 * ((x - mu) / sigma) ** 2) return coefficient * exponent print(f"Peak density at x=0: {gaussian_pdf(0.0):.4f} 🔔") # 0.3989 print(f"Density at 1 std dev (x=1): {gaussian_pdf(1.0):.4f} 📉") # 0.2420 ``` The 68-95-99.7 Empirical Rule governs Gaussian curves: $68.2\%$ within $1\sigma$, $95.4\%$ within $2\sigma$, and $99.7\%$ within $3\sigma$! 🔔 --- ### Question In a standard normal distribution with mean $\mu=0$ and standard deviation $\sigma=1$, approximately what percentage of data falls within $\pm 1\sigma$? 🧠- [ ] a. Approximately 68.2% of all data 🔔 - [ ] b. 99.9% of all data - [ ] c. Exactly 50.0% of all data - [ ] d. 10.0% of all data --- ### Challenge Write `gaussian_pdf(x, mu, sigma)` using `math.exp` and `math.sqrt`. Evaluate at `x=0, mu=0, sigma=1` and print round(val, 2). 🎯 <details> <summary>Solution</summary> ```python import math def gaussian_pdf(x, mu=0.0, sigma=1.0): c = 1.0 / (sigma * math.sqrt(2 * math.pi)) return c * math.exp(-0.5 * ((x - mu) / sigma) ** 2) val = gaussian_pdf(0) print(round(val, 2)) ``` </details>