Geometric: Create a Geometric distribution

View source: R/Geometric.R

GeometricR Documentation

Create a Geometric distribution


The Geometric distribution can be thought of as a generalization of the Bernoulli() distribution where we ask: "if I keep flipping a coin with probability p of heads, what is the probability I need k flips before I get my first heads?" The Geometric distribution is a special case of Negative Binomial distribution.


Geometric(p = 0.5)



The success probability for the distribution. p can be any value in [0, 1], and defaults to 0.5.


We recommend reading this documentation on, where the math will render with additional detail and much greater clarity.

In the following, let X be a Geometric random variable with success probability p = p. Note that there are multiple parameterizations of the Geometric distribution.

Support: 0 < p < 1, x = 0, 1, …

Mean: \frac{1-p}{p}

Variance: \frac{1-p}{p^2}

Probability mass function (p.m.f):

P(X = x) = p(1-p)^x,

Cumulative distribution function (c.d.f):

P(X ≤ x) = 1 - (1-p)^{x+1}

Moment generating function (m.g.f):

E(e^{tX}) = \frac{pe^t}{1 - (1-p)e^t}


A Geometric object.

See Also

Other discrete distributions: Bernoulli(), Binomial(), Categorical(), HurdleNegativeBinomial(), HurdlePoisson(), HyperGeometric(), Multinomial(), NegativeBinomial(), Poisson(), ZINegativeBinomial(), ZIPoisson(), ZTNegativeBinomial(), ZTPoisson()



X <- Geometric(0.3)

random(X, 10)

pdf(X, 2)
log_pdf(X, 2)

cdf(X, 4)
quantile(X, 0.7)

distributions3 documentation built on Sept. 7, 2022, 5:07 p.m.