- rv_discrete.expect(func=None, args=(), loc=0, lb=None, ub=None, conditional=False)¶
Calculate expected value of a function with respect to the distribution for discrete distribution.
func : callable, optional
Function for which the expectation value is calculated. Takes only one argument. The default is the identity mapping f(k) = k.
args : tuple, optional
Shape parameters of the distribution.
loc : float, optional
Location parameter. Default is 0.
lb, ub : int, optional
Lower and upper bound for integration, default is set to the support of the distribution, inclusive (ul <= k <= ub).
conditional : bool, 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 ul <= k <= ub). Default is False.
expect : float
- function is not vectorized
- accuracy: uses self.moment_tol as stopping criterium for heavy tailed distribution e.g. zipf(4), accuracy for mean, variance in example is only 1e-5, increasing precision (moment_tol) makes zipf very slow
- suppnmin=100 internal parameter for minimum number of points to evaluate could be added as keyword parameter, to evaluate functions with non-monotonic shapes, points include integers in (-suppnmin, suppnmin)
- uses maxcount=1000 limits the number of points that are evaluated to break loop for infinite sums (a maximum of suppnmin+1000 positive plus suppnmin+1000 negative integers are evaluated)