bundles / scipy latest / scipy / stats / _distn_infrastructure / rv_discrete / expect
function
scipy.stats._distn_infrastructure:rv_discrete.expect
Signature
def expect ( self , func = None , args = () , loc = 0 , lb = None , ub = None , conditional = False , maxcount = 1000 , tolerance = 1e-10 , chunksize = 32 ) Summary
Calculate expected value of a function with respect to the distribution for discrete distribution by numerical summation.
Parameters
func: callable, optionalFunction for which the expectation value is calculated. Takes only one argument. The default is the identity mapping f(k) = k.
args: tuple, optionalShape parameters of the distribution.
loc: float, optionalLocation parameter. Default is 0.
lb, ub: int, optionalLower and upper bound for the summation, default is set to the support of the distribution, inclusive (
lb <= k <= ub).conditional: bool, optionalIf 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 thatlb <= k <= ub). Default is False.maxcount: int, optionalMaximal number of terms to evaluate (to avoid an endless loop for an infinite sum). Default is 1000.
tolerance: float, optionalAbsolute tolerance for the summation. Default is 1e-10.
chunksize: int, optionalIterate over the support of a distributions in chunks of this size. Default is 32.
Returns
expect: floatExpected 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.
Aliases
-
scipy.stats.rv_discrete.expect