expectation: Computes expectations from reference measures

View source: R/Bayes_spaces.R

expectationR Documentation

Computes expectations from reference measures

Description

Computes expectations from reference measures

Usage

expectation(measure, f, ..., method)

## S3 method for class 'ReferenceMeasure'
expectation(
  measure,
  f,
  ...,
  method = c("default", "sample", "MonteCarlo", "integration"),
  tol = 0.01
)

## S3 method for class 'ReferenceMeasureDiscrete'
expectation(measure, f, ..., method = c("sample"))

Arguments

measure

the (probability) measure to compute the expectation from

f

a real valued random variable, represented as a vectorized function, for which the expectation shall be computed.

...

further arguments to f or the method used

method

a method to be selected. Typical methods are "sample", "MonteCarlo" and "integrate", but only sample is availabel for all reference measures. "sample" uses the prestored sample, "MonteCarlo" uses the simulated function of the reference measure, and "integrate" uses numerical integration. Typically the prestored integration sample performs well with derivatives measures derived ReferenceMeasureUniform, ReferenceMeasusureTransformed, where it proves a dense grid in the area of measure, and ReferenceMeasure discrete where it uses precise computation using a weighted sample. For Cartesian products involving more than one continues measure due to the curse of dimensionality typically only MonteCarlo is expected to work reasonably well.

tol

the absolute or relative tolerance (whichever is larger). accepted for methods with tolerance control.

Value

the numerically computed expected value of f with respect to the measure. The method

Methods (by class)

  • expectation(ReferenceMeasure): general method supporting only the "sample" method.

  • expectation(ReferenceMeasureDiscrete): a computing the results explicitly

See Also

Other ReferenceMeasures: B2N01, ReferenceMeasureDiscrete(), ReferenceMeasureTransformed(), ReferenceMeasureUniform(), StdReferenceMeasureUnif01, getSample(), isInDomain()

Examples

m <- ReferenceMeasureUniform(0,10)
expectation(m, function(x) x^2)


DistributionalDDA documentation built on Oct. 20, 2026, 5:06 p.m.