The Logarithmic distribution is a discrete probability distribution derived from the logarithmic series. It is useful in modeling the abundance of species and other phenomena where the frequency of an event follows a logarithmic pattern.
dist_logarithmic(prob)We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_logarithmic.html
In the following, let \(X\) be a Logarithmic random variable with
parameter prob = \(p\).
Support: \(\{1, 2, 3, ...\}\)
Mean: \(\frac{-1}{\log(1-p)} \cdot \frac{p}{1-p}\)
Variance: \(\frac{-(p^2 + p\log(1-p))}{[(1-p)\log(1-p)]^2}\)
Probability mass function (p.m.f):
$$ P(X = k) = \frac{-1}{\log(1-p)} \cdot \frac{p^k}{k} $$
for \(k = 1, 2, 3, \ldots\)
Cumulative distribution function (c.d.f):
The c.d.f. does not have a simple closed form. It is computed using the recurrence relationship \(P(X = k+1) = \frac{p \cdot k}{k+1} \cdot P(X = k)\) starting from \(P(X = 1) = \frac{-p}{\log(1-p)}\).
Moment generating function (m.g.f):
$$ E(e^{tX}) = \frac{\log(1 - pe^t)}{\log(1-p)} $$
for \(pe^t < 1\)
dist <- dist_logarithmic(prob = c(0.33, 0.66, 0.99))
dist
#> <distribution[3]>
#> [1] Logarithmic(0.33) Logarithmic(0.66) Logarithmic(0.99)
mean(dist)
#> [1] 1.229875 1.799369 21.497577
variance(dist)
#> [1] 0.3230419 2.0545331 1687.6118748
support(dist)
#> <support_region[3]>
#> [1] N+ N+ N+
generate(dist, 10)
#> [[1]]
#> [1] 1 1 1 2 1 1 1 1 1 1
#>
#> [[2]]
#> [1] 1 2 1 1 9 1 1 3 1 3
#>
#> [[3]]
#> [1] 20 2 1 7 105 1 6 2 23 1
#>
density(dist, 2)
#> [1] 0.1359627 0.2018892 0.1064130
density(dist, 2, log = TRUE)
#> [1] -1.995375 -1.600036 -2.240427
cdf(dist, 4)
#> [1] 0.9972938 0.9464773 0.4437691
quantile(dist, 0.7)
#> [1] 1 2 16