Last chance! 50% off unlimited learning
Sale ends in
Random numbers for the sum of random variable with negative binomial distributions.
rSnbinom(n = 1, size = NULL, prob = NULL, mu = NULL)
number of observations.
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.
probability of success in each trial. 0 < prob <= 1.
alternative parametrization via mean.
rSnbinom returns random number
rSnbinom returns random numbers for the sum of random variable with negative binomial distributions
Other Distribution of sum of random variable with negative binomial distributions:
dSnbinom()
,
pSnbinom()
,
qSnbinom()
# NOT RUN {
alpha <- c(2.1, 2.05, 2)
mu <- c(10, 30, 20)
rep <- 100000
distEmpirique <- rSnbinom(n=rep, size=alpha, mu=mu)
tabledistEmpirique <- rep(0, 301)
names(tabledistEmpirique) <- as.character(0:300)
tabledistEmpirique[names(table(distEmpirique))] <- table(distEmpirique)/rep
plot(0:300, dSnbinom(0:300, size=alpha, mu=mu), type="h", bty="n",
xlab="x", ylab="Density", ylim=c(0,0.02))
plot_add(0:300, tabledistEmpirique, type="l", col="red")
legend(x=200, y=0.02, legend=c("Empirical", "Theoretical"),
text.col=c("red", "black"), bty="n")
# }
Run the code above in your browser using DataLab