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, ...)The expected value \(E[g(X)]\).
x <- poisson_dist(5)
expectation(x, identity)
#> [1] 5
expectation(x, function(k) k^2)
#> [1] 30