R语言t分布

在概率论和统计学中,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

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值