Last chance! 50% off unlimited learning
Sale ends in
Density, distribution function, quantile function and random generation for the positive-geometric distribution.
dposgeom(x, prob, log = FALSE)
pposgeom(q, prob)
qposgeom(p, prob)
rposgeom(n, prob)
vector of quantiles.
vector of probabilities.
number of observations.
Fed into runif
.
vector of probabilities of success (of an ordinary geometric distribution). Short vectors are recycled.
logical.
dposgeom
gives the density,
pposgeom
gives the distribution function,
qposgeom
gives the quantile function, and
rposgeom
generates random deviates.
The positive-geometric distribution is a geometric distribution but with
the probability of a zero being zero. The other probabilities are scaled
to add to unity.
The mean therefore is
As prob
is not permitted here.
# NOT RUN {
prob <- 0.75; y <- rposgeom(n = 1000, prob)
table(y)
mean(y) # Sample mean
1 / prob # Population mean
(ii <- dposgeom(0:7, prob))
cumsum(ii) - pposgeom(0:7, prob) # Should be 0s
table(rposgeom(100, prob))
table(qposgeom(runif(1000), prob))
round(dposgeom(1:10, prob) * 1000) # Should be similar
# }
# NOT RUN {
x <- 0:5
barplot(rbind(dposgeom(x, prob), dgeom(x, prob)),
beside = TRUE, col = c("blue", "orange"),
main = paste("Positive geometric(", prob, ") (blue) vs",
" geometric(", prob, ") (orange)", sep = ""),
names.arg = as.character(x), las = 1, lwd = 2)
# }
Run the code above in your browser using DataLab