f with respect to a univariate_dist object x.R/univariate_dist.R
expectation.univariate_dist.RdAssumes the support is a contiguous interval that has operations for retrieving the lower and upper bounds.
# S3 method for class 'univariate_dist'
expectation(x, g, ..., control = list())The expected value (numeric scalar), or the full
integrate() result if compute_stats = TRUE.
x <- normal(3, 4)
# E[X] for Normal(3, 4) is 3
expectation(x, function(t) t)
#> [1] 3
# E[X^2] for Exp(1) is 2
expectation(exponential(1), function(t) t^2)
#> [1] 2