计算 R 编程中的负二项式累积密度 – pnbinom()函数
R 语言中的pnbinom()
函数用于计算负二项式累积密度的值。它还创建负二项式累积分布的密度图。
Syntax: pnbinom(vec, size, prob)
Parameters:
vec: x-values for binomial density
size: Number of trials
prob: Probability
示例 1:
# R program to compute
# Negative Binomial cumulative Density
# Vector of x-values
x <- seq(0, 10, by = 1)
# Calling pnbinom() Function
y <- pnbinom(x, size = 10, prob = 0.5)
y
输出:
[1] 0.0009765625 0.0058593750 0.0192871094 0.0461425781 0.0897827148
[6] 0.1508789063 0.2272491455 0.3145294189 0.4072647095 0.5000000000
[11] 0.5880985260
示例 2:
# R program to compute
# Negative Binomial Cumulative Density
# Vector of x-values
x <- seq(0, 100, by = 1)
# Calling pnbinom() Function
y <- pnbinom(x, size = 10, prob = 0.5)
# Plot a graph
plot(y)
输出: