50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

lgcp (version 1.8)

expectation.lgcpPredict: expectation.lgcpPredict function

Description

This function requires data to have been dumped to disk: see ?dump2dir and ?setoutput. This function computes the Monte Carlo Average of a function where data from a run of lgcpPredict has been dumped to disk.

Usage

# S3 method for lgcpPredict
expectation(obj, fun, maxit = NULL, ...)

Arguments

obj

an object of class lgcpPredict

fun

a function accepting a single argument that returns a numeric vector, matrix or array object

maxit

Not used in ordinary circumstances. Defines subset of samples over which to compute expectation. Expectation is computed using information from iterations 1:maxit, where 1 is the first non-burn in iteration dumped to disk.

...

additional arguments

Value

the expectated value of that function

Details

A Monte Carlo Average is computed as: Eπ(Yt1:t2|Xt1:t2)[g(Yt1:t2)]1ni=1ng(Yt1:t2(i)) where g is a function of interest, Yt1:t2(i) is the ith retained sample from the target and n is the total number of retained iterations. For example, to compute the mean of Yt1:t2 set, g(Yt1:t2)=Yt1:t2, the output from such a Monte Carlo average would be a set of t2t1 grids, each cell of which being equal to the mean over all retained iterations of the algorithm (NOTE: this is just an example computation, in practice, there is no need to compute the mean on line explicitly, as this is already done by default in lgcpPredict).

See Also

lgcpPredict, dump2dir, setoutput