在概率论和统计学中,t-分布(t-distribution)用于根据小样本来估计呈正态分布且方差未知的总体的均值。如果总体方差已知(例如在样本数量足够多时),则应该用正态分布来估计总体均值。
t分布曲线形态与n(确切地说与自由度df)大小有关。与标准正态分布曲线相比,自由度df越小,t分布曲线愈平坦,曲线中间愈低,曲线双侧尾部翘得愈高;自由度df愈大,t分布曲线愈接近正态分布曲线,当自由度df=∞时,t分布曲线为标准正态分布曲线。
The Student t Distribution
Description
Density, distribution function, quantile function and random generation for the t distribution with df
degrees of freedom (and optional non-centrality parameter ncp
).
Usage
dt(x, df, ncp, log = FALSE) pt(q, df, ncp, lower.tail = TRUE, log.p = FALSE) qt(p, df, ncp, lower.tail = TRUE, log.p = FALSE) rt(n, df, ncp)
Arguments
| vector of quantiles. |
| vector of probabilities. |
| number of observations. If |
| degrees of freedom (> 0, maybe non-integer). |
| non-centrality parameter delta; currently except for |
| logical; if TRUE, probabilities p are given as log(p). |
| logical; if TRUE (default), probabilities are P[X ≤ x], otherwise, P[X > x]. |
####t分布
# 1.t分布中抽样函数rt
# location:x0; scale:gamma
n = 100
df <- 10
rt(n, df=df)
# 2.t分布概率密度函数
x <- seq(-10,10,0.1)
y <- dt(x,df)
plot(x,y)
# 3.t分布累积概率
# x <- seq(-20,20,0.1)
# plot(x,dt(x,df))
# P[X ≤ x]
pt(1,df=df)
# P[X > x]
pt(1,df=df,lower.tail = FALSE)
# probabilities p are given as log(p).
pt(1,df=df,log.p = TRUE)
# 4.qt函数(pt的反函数)
# 累积概率为0.95时的x值
# x <- seq(-10,10,0.1)
# plot(x,pt(x,df))
qt(0.95, df=df)
qt(0.995, df=df)