Computes \(E[g(X)]\) using truncated summation over the support. The summation is truncated at the \(1 - 10^{-12}\) quantile to ensure negligible truncation error.

# S3 method for class 'poisson_dist'
expectation(x, g, ...)

Arguments

x

A poisson_dist object.

g

A function to take the expectation of.

...

Additional arguments passed to g.

Value

The expected value \(E[g(X)]\).

Examples

x <- poisson_dist(5)
expectation(x, identity)
#> [1] 5
expectation(x, function(k) k^2)
#> [1] 30