# macroeco.models.geom_uptrunc¶

macroeco.models.geom_uptrunc = <macroeco.models._distributions.geom_uptrunc_gen object at 0x1086530d0>

An upper-truncated geometric discrete random variable.

$P(x) = \frac{(1-p)^{x} p}{1 - (1-p)^{b+1}}$

for x >= 0. geom_uptrunc takes two shape parameters: p and b, the upper limit. The loc parameter is not used.

Parameters: x : array_like quantiles q : array_like lower or upper tail probability p, b : array_like shape parameters loc : array_like, optional location parameter (default=0) size : int or tuple of ints, optional shape of random variates (default computed from input arguments ) moments : str, optional composed of letters [‘mvsk’] specifying which moments to compute where ‘m’ = mean, ‘v’ = variance, ‘s’ = (Fisher’s) skew and ‘k’ = (Fisher’s) kurtosis. (default=’mv’) Alternatively, the object may be called (as a function) to fix the shape and : location parameters returning a “frozen” discrete RV object: : rv = geom_uptrunc(p, b, loc=0) : Frozen RV object with the same methods but holding the given shape and location fixed. mu : float distribution mean b : float distribution upper limit, defaults to sum of data

Notes

The boundary p = 1 is a special case in which the ratio between successive terms of the distribution is 1 (i.e., the pmf is uniform). This arises when the mean of the distribution is precisely one-half the upper limit.

This distribution is known as the Pi distribution in the MaxEnt Theory of Ecology [1], where the p parameter is equivalent to 1 - exp(-lambda). The special case of a uniform pmf has been described as HEAP [2].

References

 [1] Harte, J. (2011). Maximum Entropy and Ecology: A Theory of Abundance, Distribution, and Energetics (p. 264). Oxford, United Kingdom: Oxford University Press.
 [2] Harte, J., Conlisk, E., Ostling, A., Green, J. L., & Smith, A. B. (2005). A theory of spatial structure in ecological communities at multiple spatial scales. Ecological Monographs, 75(2), 179-197.

Examples

>>> import macroeco.models as md

>>> # Get the geom parameters from a mean and upper limit
>>> mu = 20; b = 200
>>> p, b = md.geom_uptrunc.translate_args(mu, b)
>>> p, b
(array(0.047592556687674925), 200)

>>> # Get the pmf
>>> md.geom_uptrunc.pmf(np.arange(0, 5), p, b)
array([ 0.04759519,  0.04533002,  0.04317264,  0.04111795,  0.03916104])

>>> # Generate a rank abundance distribution
>>> rad = md.geom_uptrunc.rank(20, p, b)

>>> # Fit the geom to data