NegHypergeometric | R Documentation |
Density, distribution function, quantile function, and random generation for the negative hypergeometric distribution.
dnhyper(x, m, n, k, log = FALSE)
pnhyper(q, m, n, k, lower.tail = TRUE, log.p = FALSE)
qnhyper(p, m, n, k, lower.tail = TRUE, log.p = FALSE)
rnhyper(nn, m, n, k)
x , q |
Vector of quantiles representing the number of trials until |
m |
The number of successes in the population (e.g., the number of white balls in the urn). |
n |
The population size (e.g., the total number of balls in the urn). |
k |
The number of successes (e.g., white balls) to achieve with the sample. |
p |
Vector of probabilities, which must be between 0 and 1. |
nn |
The number of observations. If |
log , log.p |
Logical vectors. If |
lower.tail |
Logical vector. If |
A negative hypergeometric distribution (sometimes called the inverse hypergeometric distribution) models the total number of trials until k
successes occur. Compare this to the negative binomial distribution, which models the number of failures that occur until a specified number of successes has been reached. The negative hypergeometric distribution has density
p(x) = \frac{{x-1 \choose k-1}{n-x \choose m-k}}{{n \choose m}}
for x=k,k+1,...,n-m+k
.
dnhyper
gives the density, pnhyper
gives the distribution function, qnhyper
gives the quantile
function, and rnhyper
generates random deviates.
Invalid arguments will return value NaN
, with a warning.
Wilks, S. S. (1963), Mathematical Statistics, Wiley.
runif
and .Random.seed
about random number generation.
## Randomly generated data from the negative hypergeometric
## distribution.
set.seed(100)
x <- rnhyper(nn = 1000, m = 15, n = 40, k = 10)
hist(x, main = "Randomly Generated Data", prob = TRUE)
x.1 = sort(x)
y <- dnhyper(x = x.1, m = 15, n = 40, k = 10)
lines(x.1, y, col = 2, lwd = 2)
plot(x.1, pnhyper(q = x.1, m = 15, n = 40, k = 10),
type = "l", xlab = "x", ylab = "Cumulative Probabilities")
qnhyper(p = 0.20, m = 15, n = 40, k = 10, lower.tail = FALSE)
qnhyper(p = 0.80, m = 15, n = 40, k = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.