在概率论和统计学中,t-分布t-distribution)用于根据小样本来估计呈正态分布且方差未知的总体的均值。如果总体方差已知(例如在样本数量足够多时),则应该用正态分布来估计总体均值。

t分布曲线形态与n(确切地说与自由度df)大小有关。与标准正态分布曲线相比,自由度df越小,t分布曲线愈平坦,曲线中间愈低,曲线双侧尾部翘得愈高;自由度df愈大,t分布曲线愈接近正态分布曲线,当自由度df=∞时,t分布曲线为标准正态分布曲线

r语言t分布函数 参数 r语言求t分布_r语言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

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

df

degrees of freedom (> 0, maybe non-integer). df = Inf is allowed.

ncp

non-centrality parameter delta; currently except for rt(), only for abs(ncp) <= 37.62. If omitted, use the central t distribution.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

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)