statsmodels.distributions.discrete.DiscretizedCount.expect

DiscretizedCount.expect(func=None, args=(), loc=0, lb=None, ub=None, conditional=False, maxcount=1000, tolerance=1e-10, chunksize=32)

Calculate expected value of a function with respect to the distribution for discrete distribution by numerical summation.

Parameters:
funccallable, optional

Function for which the expectation value is calculated. Takes only one argument. The default is the identity mapping f(k) = k.

argstuple, optional

Shape parameters of the distribution.

locfloat, optional

Location parameter. Default is 0.

lb, ubint, optional

Lower and upper bound for the summation, default is set to the support of the distribution, inclusive (lb <= k <= ub).

conditionalbool, optional

If true then the expectation is corrected by the conditional probability of the summation interval. The return value is the expectation of the function, func, conditional on being in the given interval (k such that lb <= k <= ub). Default is False.

maxcountint, optional

Maximal number of terms to evaluate (to avoid an endless loop for an infinite sum). Default is 1000.

tolerancefloat, optional

Absolute tolerance for the summation. Default is 1e-10.

chunksizeint, optional

Iterate over the support of a distributions in chunks of this size. Default is 32.

Returns:
expectfloat

Expected value.

Notes

For heavy-tailed distributions, the expected value may or may not exist, depending on the function, func. If it does exist, but the sum converges slowly, the accuracy of the result may be rather low. For instance, for zipf(4), accuracy for mean, variance in example is only 1e-5. increasing maxcount and/or chunksize may improve the result, but may also make zipf very slow.

The function is not vectorized.