macroeco.models.expon = <macroeco.models._distributions.expon_gen object at 0x108661c10>

An exponential continuous random variable.

\[f(x) = \lambda e^{-\lambda x}\]

for x >= 0. The loc and scale parameters are not used.


x : array_like


q : array_like

lower or upper tail probability

lam : array_like

shape parameters

loc : array_like, optional

location parameter (default=0)

scale : array_like, optional

scale parameter (default=1)

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, :

location, and scale parameters returning a “frozen” continuous RV object: :

rv = expon(lam, loc=0, scale=1) :

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

mu : float

distribution mean


>>> import macroeco.models as md
>>> import numpy as np
>>> # Get the rate parameter of the exponential distribution from a mean
>>> md.expon.translate_args(20)
>>> # Get the pdf
>>> md.expon.pdf(np.linspace(0.1, 10, num=10), 0.05)
array([ 0.04975062,  0.04708823,  0.04456831,  0.04218324,  0.03992581,
    0.03778919,  0.0357669 ,  0.03385284,  0.03204121,  0.03032653])
>>> # Get the cdf
>>> md.expon.cdf(np.linspace(0.1, 10, num=10), 0.05)
array([ 0.00498752,  0.05823547,  0.10863386,  0.15633518,  0.20148378,
    0.24421626,  0.28466191,  0.32294313,  0.35917572,  0.39346934])
>>> # Get the ppf
>>> md.expon.ppf(0.8, 0.05)
>>> # Draw a random sample
>>> samp = md.expon.rvs(0.05, size=100)
>>> # Fit the model to data
>>> md.expon.fit_mle(samp)


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