概述
若n个相互独立的随机变量ξ₁,ξ₂,...,ξn ,均服从标准正态分布(也称独立同分布于标准正态分布),则这n个服从标准正态分布的随机变量的平方和构成一新的随机变量,其分布规律称为卡方分布(chi-square distribution)。
The (non-central) Chi-Squared Distribution
Description
Density, distribution function, quantile function and random generation for the chi-squared (chi^2) distribution with df
degrees of freedom and optional non-centrality parameter ncp
.
Usage
dchisq(x, df, ncp = 0, log = FALSE) pchisq(q, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) qchisq(p, df, ncp = 0, lower.tail = TRUE, log.p = FALSE) rchisq(n, df, ncp = 0)
Arguments
x, q | vector of quantiles. |
p | vector of probabilities. |
n | number of observations. If |
df | degrees of freedom (non-negative, but can be non-integer). |
ncp | non-centrality parameter (non-negative). |
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]. |
####卡方(chisq)分布
# 1.卡方分布中抽样函数rchisq
n = 100
df <- 10
rchisq(n, df, ncp = 0)
# 2.卡方分布概率密度函数
x <- seq(0,30,0.1) # x为非负整数,表达次数。
y <- dchisq(x,df)
plot(x,y)
# 3.卡方分布累积概率
x <- seq(1,20,0.1)
plot(x,dchisq(x,df=10))
# P[X ≤ x]
pchisq(5, df=10)
# P[X > x]
pchisq(5, df=10,lower.tail = FALSE)
# probabilities p are given as log(p).
pchisq(5, df=10,log.p = TRUE)
# 4.qchisq函数(pchisq的反函数)
# 累积概率为0.95时的x值
qchisq(0.95, df=1)
qchisq(0.95, df=10)
qchisq(0.95, df=100)
最后
以上就是默默菠萝为你收集整理的R语言卡方(chisq)分布的全部内容,希望文章能够帮你解决R语言卡方(chisq)分布所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复