Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dist_geometric

The Geometric Distribution


Description

The Geometric distribution can be thought of as a generalization of the dist_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. [Stable]

Usage

dist_geometric(prob)

Arguments

prob

probability of success in each trial. 0 < prob <= 1.

Details

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

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}

See Also

Examples

dist <- dist_geometric(prob = c(0.2, 0.5, 0.8))

dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)

generate(dist, 10)

density(dist, 2)
density(dist, 2, log = TRUE)

cdf(dist, 4)

quantile(dist, 0.7)

distributional

Vectorised Probability Distributions

v0.2.2
GPL-3
Authors
Mitchell O'Hara-Wild [aut, cre] (<https://orcid.org/0000-0001-6729-7695>), Earo Wang [ctb] (<https://orcid.org/0000-0001-6448-5260>), Matthew Kay [ctb] (<https://orcid.org/0000-0001-9446-0419>), Alex Hayes [aut] (<https://orcid.org/0000-0002-4985-5160>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.