powered by
Computes the expected value of a vectorized, univariate function f with respect to a distribution dist. I.e., .
f
dist
expectation(dist, f, ...)# S4 method for PointMassPrior,`function` expectation(dist, f, ...)# S4 method for ContinuousPrior,`function` expectation(dist, f, rel.tol = 0.001, ...)
# S4 method for PointMassPrior,`function` expectation(dist, f, ...)
# S4 method for ContinuousPrior,`function` expectation(dist, f, rel.tol = 0.001, ...)
a univariate distribution object
distribution
a univariate function, must be vectorized
further optional arguments
numeric, relative tolerance used in adaptive gaussian quadrature to evaluate the integral
numeric
numeric, expected value of f with respect to dist
# NOT RUN { expectation(PointMassPrior(c(0, .5), c(.3, .7)), identity) # > .35 expectation( ContinuousPrior(function(x) dunif(x, .2, .4), c(.2, .4)), identity ) # > 0.3 # }
Run the code above in your browser using DataLab