macroeco.models.plnorm_ztrunc = <macroeco.models._distributions.plnorm_ztrunc_gen object at 0x108661ad0>

Zero-truncated poisson lognormal random variable.


x : array_like


q : array_like

lower or upper tail probability

mu, sigma : 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 = plnorm_ztrunc(mu, sigma, loc=0) :

  • Frozen RV object with the same methods but holding the given shape and location fixed.

mu : float

mu parameter of the poisson lognormal

sigma : float

sigma parameter of the poisson lognormal


The pmf method was adopted directly from the VGAM package in R. The VGAM R package was adopted directly from Bulmer (1974) [1]

The fit_mle function was adapted from Ethan White’s pln_solver function in macroeco_distributions (


[1]Bulmer, M. G. (1974). On fitting the poisson lognormal distribution to species bundance data. Biometrics, 30, 101-110.


>>> import macroeco.models as md
>>> # Get the pmf for the zero-truncated poisson lognormal with mu = -1
>>> # and sigma = 3
>>> md.plnorm_ztrunc.pmf(np.arange(1, 11), -1, 3)
array([ 0.27334111,  0.12990549,  0.08013071,  0.05598538,  0.04206434,
    0.03314746,  0.02701614,  0.02257919,  0.019242  ,  0.01665499])
>>> md.plnorm_ztrunc.pmf([1, 50, 1000], 2.34, 5)
array([  9.27474648e-02,   2.12916164e-03,   7.36783061e-05])
>>> # Get the CDF
>>> md.plnorm_ztrunc.cdf([1, 15, 10000], mu=.1, sigma=2)
array([ 0.27575055,  0.84270355,  0.99999442])
>>> # Rank abundance distribution. For speed, set crit = 0 or else the
>>> # calculation is very slow.
>>> md.plnorm_ztrunc.rank(20, 1, 1, crit=0, upper=40)
array([  1.,   1.,   2.,   2.,   2.,   2.,   2.,   3.,   3.,   4.,   5.,
     5.,   6.,   6.,   7.,   7.,   8.,  11.,  14.,  22.])
>>> # Fit the the plnorm to data
>>> data = np.array([1,1,1,1,1,2,2,2,3,3,4,4,5,5,6,6,12,45,67])
>>> md.plnorm_ztrunc.fit_mle(data)
(0.19056468723097392, 1.7698965441710266)


rvs(mu, sigma, loc=0, size=1) Random variates.
pmf(x, mu, sigma, loc=0) Probability mass function.
logpmf(x, mu, sigma, loc=0) Log of the probability mass function.
cdf(x, mu, sigma, loc=0) Cumulative density function.
logcdf(x, mu, sigma, loc=0) Log of the cumulative density function.
sf(x, mu, sigma, loc=0) Survival function (1-cdf — sometimes more accurate).
logsf(x, mu, sigma, loc=0) Log of the survival function.
ppf(q, mu, sigma, loc=0) Percent point function (inverse of cdf — percentiles).
isf(q, mu, sigma, loc=0) Inverse survival function (inverse of sf).
stats(mu, sigma, loc=0, moments=’mv’) Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
entropy(mu, sigma, loc=0) (Differential) entropy of the RV.
expect(func, mu, sigma, loc=0, lb=None, ub=None, conditional=False) Expected value of a function (of one argument) with respect to the distribution.
median(mu, sigma, loc=0) Median of the distribution.
mean(mu, sigma, loc=0) Mean of the distribution.
var(mu, sigma, loc=0) Variance of the distribution.
std(mu, sigma, loc=0) Standard deviation of the distribution.
interval(alpha, mu, sigma, loc=0) Endpoints of the range that contains alpha percent of the distribution