NegBinomial(stats)
NegBinomial()所属R语言包:stats
The Negative Binomial Distribution
负二项分布
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Density, distribution function, quantile function and random generation for the negative binomial distribution with parameters size and prob.
密度分布函数,分位数函数和随机生成的负二项分布参数size和prob。
用法----------Usage----------
dnbinom(x, size, prob, mu, log = FALSE)
pnbinom(q, size, prob, mu, lower.tail = TRUE, log.p = FALSE)
qnbinom(p, size, prob, mu, lower.tail = TRUE, log.p = FALSE)
rnbinom(n, size, prob, mu)
参数----------Arguments----------
参数:x
vector of (non-negative integer) quantiles.
矢量(非负整数)位数。
参数: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,长度是所需的数量。
参数:size
target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.
试验取得成功,或分散的目标参数(伽玛混合分布的形状参数)。必须严格正,不必为整数。
参数:prob
probability of success in each trial. 0 < prob <= 1.
在每次试验成功的概率。 0 < prob <= 1。
参数:mu
alternative parametrization via mean: see "Details".
替代参数化通过的意思是:看到“详细资料”。
参数: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 negative binomial distribution with size = n and prob = p has density
size= n和prob= p有密度的负二项分布
for x = 0, 1, 2, …, n > 0 and 0 < p ≤ 1.
x = 0, 1, 2, …,n > 0和0 < p ≤ 1。
This represents the number of failures which occur in a sequence of Bernoulli trials before a target number of successes is reached. The mean is n(1-p)/p and variance n(1-p)/p^2.
这代表伯努利试验序列中的故障发生之前,一个成功的目标数量达到数。平均n(1-p)/p和方差n(1-p)/p^2。
A negative binomial distribution can also arise as a mixture of Poisson distributions with mean distributed as a gamma distribution (seepgamma) with scale parameter (1 - prob)/prob and shape parameter size. (This definition allows non-integer values of size.)
负二项分布也出现与平均分布为伽玛分布的泊松分布的混合物(见pgamma)规模参数(1 - prob)/prob和形状参数size。 (这个定义允许非整数的值size)。
An alternative parametrization (often used in ecology) is by the mean mu, and size, the dispersion parameter, where prob = size/(size+mu). The variance is mu + mu^2/size in this parametrization.
另一种参数化(通常是在生态环境中使用)是由平均mu,size,色散参数,其中prob=size/(size+mu)。方差是mu + mu^2/size在这个参数化。
If an element of x is not integer, the result of dnbinom is zero, with a warning.
如果一个元素x是不是整数,结果“dnbinom是零,警告。
The quantile is defined as the smallest value x such that F(x) ≥ p, where F is the distribution function.
位数被定义为最小的值x等F(x) ≥ p,其中F是分布函数。
值----------Value----------
dnbinom gives the density, pnbinom gives the distribution function, qnbinom gives the quantile function, and rnbinom generates random deviates.
dnbinom给人的密度,pnbinom给出了分布函数,qnbinom给人的分量功能,rnbinom产生随机的偏离。
Invalid size or prob will result in return value NaN, with a warning.
无效size或prob将导致返回值NaN警告。
源----------Source----------
dnbinom computes via binomial probabilities, using code contributed by Catherine Loader (see dbinom).
dnbinom通过二项式概率计算,使用由凯瑟琳装载机贡献的代码(见dbinom)。
pnbinom uses pbeta.
pnbinom使用pbeta的。
qnbinom uses the Cornish–Fisher Expansion to include a skewness correction to a normal approximation, followed by a search.
qnbinom使用康沃尔-Fisher展开,包括偏校正到正常的逼近,搜索。
rnbinom uses the derivation as a gamma mixture of Poissons, see
rnbinom使用伽玛混合的泊松推导,见
Devroye, L. (1986) Non-Uniform Random Variate Generation. Springer-Verlag, New York. Page 480.
devroye,L.(1986)非均匀随机变量生成。施普林格出版社,纽约。页480。
参见----------See Also----------
Distributions for standard distributions, including dbinom for the binomial, dpois for the Poisson and dgeom for the geometric distribution, which is a special case of the negative binomial.
为标准的分布,包括分布dbinom二项式,dpois泊松和dgeom几何分布,这是一个负二项分布的特例。
举例----------Examples----------
require(graphics)
x <- 0:11
dnbinom(x, size = 1, prob = 1/2) * 2^(1 + x) # == 1[== 1]
126 / dnbinom(0:8, size = 2, prob = 1/2) #- theoretically integer[ - 理论上的整数]
## Cumulative ('p') = Sum of discrete prob.s ('d'); Relative error :[#累积(P)= SUM的离散prob.s(D);相对误差:]
summary(1 - cumsum(dnbinom(x, size = 2, prob = 1/2)) /
pnbinom(x, size = 2, prob = 1/2))
x <- 0:15
size <- (1:20)/4
persp(x,size, dnb <- outer(x, size, function(x,s) dnbinom(x,s, prob= 0.4)),
xlab = "x", ylab = "s", zlab="density", theta = 150)
title(tit <- "negative binomial density(x,s, pr = 0.4) vs. x & s")
image (x,size, log10(dnb), main= paste("log [",tit,"]"))
contour(x,size, log10(dnb),add=TRUE)
## Alternative parametrization[#替代参数化]
x1 <- rnbinom(500, mu = 4, size = 1)
x2 <- rnbinom(500, mu = 4, size = 10)
x3 <- rnbinom(500, mu = 4, size = 100)
h1 <- hist(x1, breaks = 20, plot = FALSE)
h2 <- hist(x2, breaks = h1$breaks, plot = FALSE)
h3 <- hist(x3, breaks = h1$breaks, plot = FALSE)
barplot(rbind(h1$counts, h2$counts, h3$counts),
beside = TRUE, col = c("red","blue","cyan"),
names.arg = round(h1$breaks[-length(h1$breaks)]))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|