macroeco.models.plnorm = <macroeco.models._distributions.plnorm_gen object at 0x108661550>

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(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 poisson lognormal with mu = -1 and sigma = 3
>>> md.plnorm.pmf(np.arange(1, 11), -1, 3)
array([ 0.12139284,  0.05769201,  0.03558665,  0.02486353,  0.01868109,
    0.01472104,  0.01199807,  0.01002759,  0.00854552,  0.00739661])
>>> md.plnorm.pmf([0, 50, 1000], 2.34, 5)
array([  2.86468926e-01,   1.51922299e-03,   5.25717609e-05])
>>> # Get the CDF
>>> md.plnorm.cdf([0, 15, 10000], mu=.1, sigma=2)
array([ 0.3954088 ,  0.90489995,  0.99999662])
>>> # Rank abundance distribution
>>> md.plnorm.rank(10, 1, 1, crit=0.5, upper=40)
array([  0.,   0.,   1.,   2.,   2.,   4.,   5.,   7.,   8.,  15.])
>>> # 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.fit_mle(data)
(1.3195513537335777, 1.1876220131629682)


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