Chisquare(stats)
Chisquare()所属R语言包:stats
The (non-central) Chi-Squared Distribution
(非中心),卡方分布
译者:生物统计家园网 机器人LoveR
描述----------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.
密度分布函数,分位数函数和卡方(chi^2)df度的自由和可选的非集中参数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 length(n) > 1, the length is taken to be the number required.
观测数。如果length(n) > 1,长度是所需的数量。
参数: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).
逻辑;如果为TRUE,概率P日志(P)。
参数:lower.tail
logical; if TRUE (default), probabilities are P[X ≤ x], otherwise, P[X > x].
逻辑;如果是TRUE(默认),概率P[X ≤ x],否则,“P[X > x]。
Details
详情----------Details----------
The chi-squared distribution with df= n ≥ 0 degrees of freedom has density
df = n ≥ 0自由度的卡方分布密度
for x > 0. The mean and variance are n and 2n.
x > 0。均值和方差n和2n。
The non-central chi-squared distribution with df= n degrees of freedom and non-centrality parameter ncp = λ has density
df = n度的自由和非集中参数ncp= λ有密度的非中心卡方分布
for x ≥ 0. For integer n, this is the distribution of the sum of squares of n normals each with variance one, λ being the sum of squares of the normal means; further, <br> E(X) = n + λ, Var(X) = 2(n + 2*λ), and E((X - E(X))^3) = 8(n + 3*λ).
x ≥ 0。对于整数n,这是分布n法线方差一,λ正常手段的平方的总和的平方的总和;进一步,参考 E(X) = n + λ,Var(X) = 2(n + 2*λ),E((X - E(X))^3) = 8(n + 3*λ)。
Note that the degrees of freedom df= n, can be non-integer, and also n = 0 which is relevant for non-centrality λ > 0, see Johnson et al. (1995, chapter 29).
请注意,自由度df = n,可以非整数,也n = 0这是有关非核心λ > 0,约翰逊等人。 (1995年,第29章)。
Note that ncp values larger than about 1e5 may give inaccurate results with many warnings for pchisq and qchisq.
请注意,ncp值大于约1E5可能会不准确的结果与很多pchisq和qchisq警告。
值----------Value----------
dchisq gives the density, pchisq gives the distribution function, qchisq gives the quantile function, and rchisq generates random deviates.
dchisq给人的密度,pchisq给出了分布函数,qchisq给人的分量功能,rchisq产生随机的偏离。
Invalid arguments will result in return value NaN, with a warning.
无效的参数将导致返回值NaN,一个警告。
注意----------Note----------
Supplying ncp = 0 uses the algorithm for the non-central distribution, which is not the same algorithm used if ncp is omitted. This is to give consistent behaviour in extreme cases with values of ncp very near zero.
供应ncp = 0使用算法的非中心分布,这是不使用相同的算法,如果ncp省略。这是给予一致的行为,在极端情况下ncp非常接近零值。
The code for non-zero ncp is principally intended to be used for moderate values of ncp: it will not be highly accurate, especially in the tails, for large values.
为非零ncp代码主要拟用于适度值ncp:它不会是非常准确的,尤其是在尾巴大值。
源----------Source----------
The central cases are computed via the gamma distribution.
中央的情况下,通过伽玛分布计算。
The non-central dchisq and rchisq are computed as a Poisson mixture central of chi-squares (Johnson et al, 1995, p.436).
非中央dchisq和rchisq卡广场(Johnson等,1995,p.436)中央泊松混合计算。
The non-central pchisq is for ncp < 80 computed from the Poisson mixture of central chi-squares and for larger ncp via a C translation of
非中央pchisq是ncp < 80泊松混合环驰平方计算和更大的ncp的通过一个C的翻译
Ding, C. G. (1992) Algorithm AS275: Computing the non-central chi-squared distribution function. Appl.Statist., 41 478–482.
丁,CG(1992)AS275算法:计算非中心卡方分布函数。 Appl.Statist。,41 478-482。
which computes the lower tail only (so the upper tail suffers from cancellation and a warning will be given when this is likely to be significant).
计算较低尾(所以尾巴上遭受取消时,这是很大的,将给予警告)。
The non-central qchisq is based on inversion of pchisq.
非中央的qchisq基于反演pchisq的。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
Continuous Univariate Distributions, chapters 18 (volume 1) and 29 (volume 2). Wiley, New York.
参见----------See Also----------
Distributions for other standard distributions.
其他标准分布的分布。
A central chi-squared distribution with n degrees of freedom is the same as a Gamma distribution with shape a = n/2 and scale s = 2. Hence, see dgamma for the Gamma distribution.
中央n自由度的卡方分布与shapea = n/2和scales = 2 Gamma分布是相同的。因此,看到dgammaGamma分布。
举例----------Examples----------
require(graphics)
dchisq(1, df=1:3)
pchisq(1, df= 3)
pchisq(1, df= 3, ncp = 0:4)# includes the above[包括上述]
x <- 1:10
## Chi-squared(df = 2) is a special exponential distribution[#卡方(DF = 2)是一种特殊的指数分布]
all.equal(dchisq(x, df=2), dexp(x, 1/2))
all.equal(pchisq(x, df=2), pexp(x, 1/2))
## non-central RNG -- df=0 with ncp > 0: Z0 has point mass at 0![#非中央的RNG - DF = 0> 0与NCP:Z0的0点质量!]
Z0 <- rchisq(100, df = 0, ncp = 2.)
graphics::stem(Z0)
## Not run: ## visual testing[#无法运行:#视觉检测]
## do P-P plots for 1000 points at various degrees of freedom[#为1000点,在不同程度上的自由PP图]
L <- 1.2; n <- 1000; pp <- ppoints(n)
op <- par(mfrow = c(3,3), mar= c(3,3,1,1)+.1, mgp= c(1.5,.6,0),
oma = c(0,0,3,0))
for(df in 2^(4*rnorm(9))) {
plot(pp, sort(pchisq(rr <- rchisq(n,df=df, ncp=L), df=df, ncp=L)),
ylab="pchisq(rchisq(.),.)", pch=".")
mtext(paste("df = ",formatC(df, digits = 4)), line= -2, adj=0.05)
abline(0,1,col=2)
}
mtext(expression("P-P plots : Noncentral "*
chi^2 *"(n=1000, df=X, ncp= 1.2)"),
cex = 1.5, font = 2, outer=TRUE)
par(op)
## End(Not run)[#结束(不运行)]
## "analytical" test[#“分析”测试]
lam <- seq(0,100, by=.25)
p00 <- pchisq(0, df=0, ncp=lam)
p.0 <- pchisq(1e-300, df=0, ncp=lam)
stopifnot(all.equal(p00, exp(-lam/2)),
all.equal(p.0, exp(-lam/2)))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|