Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

Normal Distribution

参数: $\mu$ (均值), $\sigma^2$ (方差)

Probability density function (PDF):

Cumulative Distribution Function (CDF):

正态分布的CDF没有初等函数的封闭解析式。

Expectation:

Variance:

Moments:

$(n-1)!! = (n-1)(n-3)\cdots 3 \cdot 1$ 是双阶乘

Moment generating function:

Definition:

For $\mu \in \mathbb{R}$ and $\sigma > 0$, we call a distribution with the density function

the normal distribution $N(\mu, \sigma^2)$.

For $\mu = 0$ and $\sigma^2 = 1$, this reduces to the density

of the standard normal distribution $N(0, 1)$.


Theorem:

For $\mu \in \mathbb{R}$ and $\sigma > 0$, the function

is indeed a density function.


Proof: Using the substitution $y = \frac{x - \mu}{\sigma}$, so that $dx = \sigma \, dy$, we have:

where

Note that this integral exists. Consider:

We switch to polar coordinates, i.e., we substitute

We compute the Jacobian determinant:

So we obtain:

Substitute $u = \frac{r^2}{2}$, so that $du = r \, dr$:

Hence, we conclude:

.$\square$

Theorem: Let $X \sim N(\mu,\sigma^2)$ be a random variable, then


Proof:

Expectation:

Substitute $z = \frac{x - \mu}{\sigma} \Rightarrow x = \sigma z + \mu$, and $dx = \sigma dz$:

First notice that $z \cdot e^{-z^2/2}$ is an odd function. Since

we have

(Do keep in mind: if $f$ is an odd function, then

is a necessary condition of $\int_{\infty}^{\infty}f(x)dx = 0$ . Because otherwise, $f(x)=x$ is a simple counterexample.)

Moreover, we have seen in the last proof that

Therefore,

Variance:

We compute:

Again substitute $z = \frac{x - \mu}{\sigma} \Rightarrow x = \sigma z + \mu$, and $dx = \sigma dz$:

,where

In addition, since $\phi’(z) = z\phi(z)$,

Finally, we have

.$\square$

Bernoulli Distribution 伯努利分布

参数: $p$ (成功概率, $0 \le p \le 1$)

Probability mass function (PMF):

Cumulative Distribution Function (CDF):

Expectation:

Variance:

Moments:

Moment generating function:

Binomial Distribution 二项分布

参数: $n$ (试验次数), $p$ (成功概率)

Probability mass function (PMF):

Cumulative Distribution Function (CDF):

Expectation:

Variance:

Moments:

Moment generating function:

Poisson Distribution 泊松分布

参数: $\lambda$ (单位时间/面积内的平均发生率, $\lambda > 0$)

Probability mass function (PMF):

Cumulative Distribution Function (CDF):

Expectation:

Variance:

Moments:

Moment generating function:

Geometric Distribution 几何分布

参数: $p$ (成功概率)。此处定义为第 $k$ 次试验首次成功 (Support: $1, 2, \dots$)

Probability mass function (PMF):

Cumulative Distribution Function (CDF):

Expectation:

Variance:

Moments:

涉及到多重对数函数,无简单的初等函数通项。通常使用递推公式:

Moment generating function:

Uniform Distribution 均匀分布

参数: $a, b$ (区间端点, $a < b$)

Probability density function (PDF):

Cumulative Distribution Function (CDF):

Expectation:

Variance:

Moments:

Moment generating function:

Exponential Distribution 指数分布

参数: $\lambda$ (率参数, $\lambda > 0$)

Probability density function (PDF):

Cumulative Distribution Function (CDF):

Expectation:

Variance:

Moments:

Moment generating function:

Gamma Distribution 伽玛分布

参数: $\alpha$ (形状参数 shape), $\beta$ (率参数 rate, sometimes $\theta = 1/\beta$ is used as scale)

Probability density function (PDF):

Cumulative Distribution Function (CDF):

其中 $\gamma(s, x) = \int_0^x t^{s-1} e^{-t} dt$。

Expectation:

Variance:

Moments:

Moment generating function:

Chi-Squared Distribution 卡方分布

参数: $k$ (自由度 degrees of freedom, $k \in \mathbb{N}^*$)

卡方分布是伽玛分布的一个特例,其中$\alpha = k/2$, $\beta = 1/2$。

Probability density function (PDF):

Cumulative Distribution Function (CDF):

其中 $\gamma(s, x)$ 为下不完全伽玛函数,$P$ 为正则化伽玛函数。

Expectation:

Variance:

Moments:

Moment generating function:

Beta Distribution 贝塔分布

参数: $\alpha, \beta$ (形状参数 shape parameters, $\alpha > 0, \beta > 0$)

Probability density function (PDF):

其中 $B(\alpha, \beta) = \frac{\Gamma(\alpha)\Gamma(\beta)}{\Gamma(\alpha+\beta)}$ 为贝塔函数。

Cumulative Distribution Function (CDF):

其中 $B(x; \alpha, \beta) = \int_0^x t^{\alpha-1}(1-t)^{\beta-1} dt$ 为不完全贝塔函数 (Incomplete Beta Function),$I_x$ 为正则化不完全贝塔函数。

Expectation:

Variance:

Moments:

Moment generating function:

无初等函数形式,通常表示为合流超几何函数 (Confluent Hypergeometric Function):

R

在 R 语言中,处理概率分布有一套非常标准的前缀命名规则。对于每种分布(比如 norm),都有 4 个核心函数:

  • d (Density): 概率密度/质量函数 (PDF/PMF), e.g., dnorm
  • p (Probability): 累积分布函数 (CDF), e.g., pnorm
  • q (Quantile): 分位数函数 (CDF 的反函数), e.g., qnorm
  • r (Random): 生成随机数, e.g., rnorm

一、离散型分布 (Discrete)

1. Bernoulli & Binomial (伯努利与二项分布)

R 中没有专门的 bernoulli 函数,伯努利分布就是 size = 1 的二项分布。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 参数设定: n=10次试验, p=0.5成功率
n <- 10
p <- 0.5

# 1. PMF (Density): 恰好成功 5 次的概率 P(X=5)
dbinom(x = 5, size = n, prob = p)

# 2. CDF (Probability): 成功次数 <= 5 的概率 P(X<=5)
pbinom(q = 5, size = n, prob = p)

# 3. Quantile: 累积概率达到 0.95 时的成功次数
qbinom(p = 0.95, size = n, prob = p)

# 4. Random: 模拟 5 组实验,每组试验 n 次
rbinom(n = 5, size = n, prob = p)

# 特例:伯努利分布 (size = 1)
rbinom(n = 10, size = 1, prob = 0.5) # 生成 10 个 0 或 1

2. Poisson Distribution (泊松分布)

1
2
3
4
5
6
7
8
9
10
11
# 参数设定: lambda = 4
lam <- 4

# 1. PMF: 发生 3 次的概率 P(X=3)
dpois(x = 3, lambda = lam)

# 2. CDF: 发生次数 <= 3 的概率 P(X<=3)
ppois(q = 3, lambda = lam)

# 3. Random: 生成 10 个符合泊松分布的随机数
rpois(n = 10, lambda = lam)

3. Geometric Distribution (几何分布)

R 中的几何分布定义为失败次数 ($X \in \{0, 1, \dots\}$),直到第一次成功。

  • 如果使用的是 $X \in \{1, 2, \dots\}$ (第 $k$ 次首次成功),则 R 中的 x 应该是 k-1
1
2
3
4
5
6
7
8
9
10
11
12
# 参数: p = 0.2
prob <- 0.2

# 1. PMF: 在第 5 次试验首次成功 (意味着前 4 次失败)
# 公式: P(X=5 in math definition) -> dgeom(4, p)
dgeom(x = 4, prob = prob)

# 2. CDF: 在第 5 次及以前成功的概率
pgeom(q = 4, prob = prob)

# 3. Random: 生成 10 个随机样本 (返回的是失败次数)
rgeom(n = 10, prob = prob)

二、连续型分布 (Continuous)

4. Uniform Distribution (均匀分布)

1
2
3
4
5
6
7
8
9
10
11
12
# 参数: 区间 [a, b] -> min=0, max=10
a <- 0
b <- 10

# 1. PDF: 在 x=5 处的密度 (对于均匀分布是常数 1/(b-a))
dunif(x = 5, min = a, max = b)

# 2. CDF: P(X <= 5)
punif(q = 5, min = a, max = b)

# 3. Random: 生成 5 个 [0, 10] 之间的随机数
runif(n = 5, min = a, max = b)

5. Exponential Distribution (指数分布)

1
2
3
4
5
6
7
8
9
10
11
# 参数: lambda (rate) = 0.5
lam <- 0.5

# 1. PDF: f(x) at x=2
dexp(x = 2, rate = lam)

# 2. CDF: P(X <= 2) = 1 - e^(-lambda * 2)
pexp(q = 2, rate = lam)

# 3. Random: 生成符合指数分布的随机数
rexp(n = 5, rate = lam)

6. Normal Distribution (正态分布)

注意:R 使用标准差 sd ($\sigma$) 作为参数,而不是方差 ($\sigma^2$)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 参数: mean=0, sd=1 (标准正态)
mu <- 0
sigma <- 1

# 1. PDF: f(x)
dnorm(x = 1.96, mean = mu, sd = sigma)

# 2. CDF: P(X <= 1.96) ≈ 0.975
pnorm(q = 1.96, mean = mu, sd = sigma)

# 3. Quantile: 查表逆运算,P(X <= z) = 0.975,求 z
qnorm(p = 0.975, mean = mu, sd = sigma) # 结果约为 1.96

# 4. Random: 生成正态分布数据
rnorm(n = 10, mean = mu, sd = sigma)

7. Gamma Distribution (伽玛分布)

R 支持 rate ($\beta$) 或 scale ($1/\beta$) 参数。

1
2
3
4
5
6
7
8
9
10
11
12
# 参数: alpha (shape) = 2, beta (rate) = 0.5
alpha <- 2
beta <- 0.5

# 1. PDF: f(x)
dgamma(x = 4, shape = alpha, rate = beta)

# 2. CDF: F(x)
pgamma(q = 4, shape = alpha, rate = beta)

# 3. Random
rgamma(n = 10, shape = alpha, rate = beta)