Description Usage Arguments Details Value See Also Examples
This function creates an object of class MonteCarloAverage
. The purpose of the function is to compute
Monte Carlo expectations online in the function lgcpPredict
, it is set in the argument gridmeans
of the argument output.control
.
1 | MonteCarloAverage(funlist, lastonly = TRUE)
|
funlist |
a character vector of names of functions, each accepting single argument Y |
lastonly |
compute average using only time T? (see ?lgcpPredict for definition of T) |
A Monte Carlo Average is computed as:
E_{π(Y_{t_1:t_2}|X_{t_1:t_2})}[g(Y_{t_1:t_2})] \approx \frac1n∑_{i=1}^n g(Y_{t_1:t_2}^{(i)})
where g is a function of interest, Y_{t_1:t_2}^{(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 Y_{t_1:t_2} set,
g(Y_{t_1:t_2}) = Y_{t_1:t_2},
the output from such a Monte Carlo average would be a set of t_2-t_1 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 defaul in lgcpPredict
).
For further examples, see below. The option last=TRUE
computes,
E_{π(Y_{t_1:t_2}|X_{t_1:t_2})}[g(Y_{t_2})],
so in this case the expectation over the last time point only is computed. This can save computation time.
object of class MonteCarloAverage
setoutput, lgcpPredict, GAinitialise, GAupdate, GAfinalise, GAreturnvalue, exceedProbs
1 2 3 4 5 6 7 8 | fun1 <- function(x){return(x)} # gives the mean
fun2 <- function(x){return(x^2)} # computes E(X^2). Can be used with the
# mean to compute variances, since
# Var(X) = E(X^2) - E(X)^2
fun3 <- exceedProbs(c(1.5,2,3)) # exceedance probabilities,
#see ?exceedProbs
mca <- MonteCarloAverage(c("fun1","fun2","fun3"))
mca2 <- MonteCarloAverage(c("fun1","fun2","fun3"),lastonly=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.