weighted_trajectory_variation_multivariate | R Documentation |
Calculation of the scaled/weighted average variation of the C trajectories with respect to their individual sub-posterior means
weighted_trajectory_variation_multivariate( x_samples, normalised_weights, sub_posterior_means, inv_precondition_matrices )
sub_posterior_means |
matrix with C rows of sub-posterior means |
inv_precondition_matrices |
list of length m of inverse preconditioning matrices |
list |
where x_samples[[i]] ith collection of the C trajectories |
the approximated expectation of nu_j
N <- 10 C <- 4 d <- 3 x_samples <- lapply(1:N, function(i) mvrnormArma(C, rep(0,d), diag(1,d))) normalised_weights <- rep(1/N, N) sub_posterior_means <- mvrnormArma(C, rep(0,d), diag(1,d)) precond <- lapply(1:C, function(c) diag(c, d)) inv_precond <- lapply(precond, solve) weighted_trajectory_variation_multivariate(x_samples = x_samples, normalised_weights = normalised_weights, sub_posterior_means = sub_posterior_means, inv_precondition_matrices = inv_precond) # should be equal to the result of this: sum(sapply(1:N, function(i) { sum(sapply(1:C, function(c) { diff <- x_samples[[i]][c,]-sub_posterior_means[c,] return(t(diff) %*% inv_precond[[c]] %*% diff) }))/C }))/N
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.