macroeco.models.expon_uptrunc = <macroeco.models._distributions.expon_uptrunc_gen object at 0x108661bd0>

An upper-truncated exponential continuous random variable.

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

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


x : array_like


q : array_like

lower or upper tail probability

lam, b : 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_uptrunc(lam, b, loc=0, scale=1) :

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

mu : float

distribution mean

b : float

distribution upper limit, defaults to sum of data


>>> import macroeco.models as md
>>> import numpy as np
>>> # Get the rate parameter of the exponential distribution from a mean
>>> md.expon_uptrunc.translate_args(20, 100)
(array(0.04801007549722518), 100)
>>> # Get the pdf
>>> md.expon_uptrunc.pdf(np.linspace(0.1, 10, num=10), 0.05, 100)
array([ 0.05008812,  0.04740766,  0.04487064,  0.0424694 ,  0.04019665,
    0.03804554,  0.03600953,  0.03408249,  0.03225857,  0.03053226])
>>> # Get the cdf
>>> md.expon_uptrunc.cdf(np.linspace(0.1, 10, num=10), 0.05, 100)
array([ 0.00502135,  0.05863052,  0.10937079,  0.15739571,  0.20285058,
    0.24587294,  0.28659296,  0.32513386,  0.36161225,  0.3961385 ])
>>> # Get the ppf
>>> md.expon_uptrunc.ppf(0.8, 0.05, 100)
>>> # Draw a random sample
>>> samp = md.expon_uptrunc.rvs(0.05, 100, size=100)
>>> # Fit the model to data
>>> md.expon_uptrunc.fit_mle(samp)
(0.06080396315704938, 1644.6296393823973)


rvs(lam, b, loc=0, scale=1, size=1) Random variates.
pdf(x, lam, b, loc=0, scale=1) Probability density function.
logpdf(x, lam, b, loc=0, scale=1) Log of the probability density function.
cdf(x, lam, b, loc=0, scale=1) Cumulative density function.
logcdf(x, lam, b, loc=0, scale=1) Log of the cumulative density function.
sf(x, lam, b, loc=0, scale=1) Survival function (1-cdf — sometimes more accurate).
logsf(x, lam, b, loc=0, scale=1) Log of the survival function.
ppf(q, lam, b, loc=0, scale=1) Percent point function (inverse of cdf — percentiles).
isf(q, lam, b, loc=0, scale=1) Inverse survival function (inverse of sf).
moment(n, lam, b, loc=0, scale=1) Non-central moment of order n
stats(lam, b, loc=0, scale=1, moments=’mv’) Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).
entropy(lam, b, loc=0, scale=1) (Differential) entropy of the RV.
fit(data, lam, b, loc=0, scale=1) Parameter estimates for generic data.
expect(func, lam, b, 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, b, loc=0, scale=1) Median of the distribution.
mean(lam, b, loc=0, scale=1) Mean of the distribution.
var(lam, b, loc=0, scale=1) Variance of the distribution.
std(lam, b, loc=0, scale=1) Standard deviation of the distribution.
interval(alpha, lam, b, loc=0, scale=1) Endpoints of the range that contains alpha percent of the distribution