R语言超几何分布

它描述了由有限个(m+n)物件中抽出k个物件,成功抽出指定种类的物件的次数(不归还)。

超几何分布是统计学上一种离散概率分布。它描述了从有限N个物件(其中包含M个指定种类的物件)中抽出n个物件,成功抽出该指定种类的物件的次数(不放回)。称为超几何分布,是因为其形式与“超几何函数”的级数展式的系数有关。 [1] 

超几何分布中的参数是N,n,M,上述超几何分布记作X~H(N,n,M)。

The Hypergeometric Distribution

Description

Density, distribution function, quantile function and random generation for the hypergeometric distribution.

Usage

dhyper(x, m, n, k, log = FALSE)
phyper(q, m, n, k, lower.tail = TRUE, log.p = FALSE)
qhyper(p, m, n, k, lower.tail = TRUE, log.p = FALSE)
rhyper(nn, m, n, k)

Arguments

x, q

vector of quantiles representing the number of white balls drawn without replacement from an urn which contains both black and white balls.

m

the number of white balls in the urn.

n

the number of black balls in the urn.

k

the number of balls drawn from the urn, hence must be in 0,1,…, m+n.

p

probability, it must be between 0 and 1.

nn

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

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].

####超几何分布
# 1.超几何分布中抽样函数rhyper
nn <- 100
m=100 
n=200
k=30
rhyper(nn, m,n,k)

# 2.超几何分布概率密度函数
x <- seq(1,100)
y <- dhyper(x,m,n,k=50)
plot(x,y)

# 3.超几何分布累积概率
# P[X ≤ x]
phyper(10,m,n,k)
# P[X > x]
phyper(10,m,n,k,lower.tail = FALSE)

# probabilities p are given as log(p).
phyper(10,m,n,k,log.p = TRUE)

# 4.qhyper函数(phyper的反函数)
# 累积概率为0.95时的x值
# x <- seq(1,100)
# plot(x,phyper(x, m,n,k))
qhyper(0.95,m,n,k)
qhyper(0.995,m,n,k)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值