๐Ÿ› ๏ธToolsShed

Normal Distribution Calculator

Calculate probabilities and percentiles for the normal (Gaussian) distribution.

Common normal distribution coverages:

Sigma RangeCoveragez
1ฯƒ68.27%ยฑ1.000
2ฯƒ95.45%ยฑ2.000
3ฯƒ99.73%ยฑ3.000
1.96ฯƒ95.00%ยฑ1.960
2.576ฯƒ99.00%ยฑ2.576

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

์ฝ”๋“œ ๊ตฌํ˜„

import math

def norm_cdf(x):
    """Standard normal CDF using math.erfc"""
    return 0.5 * math.erfc(-x / math.sqrt(2))

def normal_cdf(x, mu=0, sigma=1):
    """Normal CDF with given mean and std dev"""
    return norm_cdf((x - mu) / sigma)

def normal_pdf(x, mu=0, sigma=1):
    """Normal probability density function"""
    return (1 / (sigma * math.sqrt(2 * math.pi))) * math.exp(-0.5 * ((x - mu) / sigma) ** 2)

# P(X < 1) for standard normal
print(f"P(X < 1) = {norm_cdf(1):.4%}")       # 84.1345%

# P(0 < X < 1) for N(0,1)
print(f"P(0<X<1) = {norm_cdf(1) - norm_cdf(0):.4%}")  # 34.1345%

# Using scipy for more features
from scipy import stats
mu, sigma = 100, 15   # IQ scores
print(f"P(IQ < 130) = {stats.norm.cdf(130, mu, sigma):.4%}")
print(f"90th percentile IQ = {stats.norm.ppf(0.90, mu, sigma):.1f}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.