log_rho_multivariate: Calculate the logarithm of rho (multivariate)

View source: R/RcppExports.R

log_rho_multivariateR Documentation

Calculate the logarithm of rho (multivariate)

Description

Calculation of the log of rho acceptance probability or weight when target is multivariate

Usage

log_rho_multivariate(x, x_mean, time, inv_precondition_matrices)

Arguments

x

an (m x n) matrix where the ith row is the ith sample

x_mean

a vector of length n (the weighted mean of x samples)

time

time T for fusion algorithm

inv_precondition_matrices

list of length m of inverse preconditioning matrices

Value

the logarithm of rho

Examples

# set covariance matrices
Sig1 <- diag(2)
Sig2 <- matrix(c(2, 0.5, 0.5, 2), nrow = 2, ncol = 2)
Sig3 <- matrix(c(4, -3.2, -3.2, 4), nrow = 2, ncol = 2)
# sample some x values and store in the rows
x <- matrix(nrow = 3, ncol = 2)
x[1,] <- mvrnormArma(N = 1, mu = c(0, 0), Sigma = Sig1)
x[2,] <- mvrnormArma(N = 1, mu = c(0, 0), Sigma = Sig2)
x[3,] <- mvrnormArma(N = 1, mu = c(0, 0), Sigma = Sig3)
# calcualte precondition matrices and their inverses
precondition_matrices <- list(Sig1, Sig2, Sig3)
inv_precondition_matrices <- lapply(precondition_matrices, solve)
inverse_sum_weights <- inverse_sum_matrices(precondition_matrices)
# calculate the weighted mean where weights are the inverse precondition matrices
x_mean <- weighted_mean_multivariate(matrix = x,
                                     weights = precondition_matrices,
                                     inverse_sum_weights = inverse_sum_weights)
# calculate logarithm of rho with time T = 0.5
log_rho_multivariate(x = x,
                     x_mean = x_mean,
                     time = 0.5,
                     inv_precondition_matrices = inv_precondition_matrices)

rchan26/hierarchicalFusion documentation built on Sept. 11, 2022, 10:30 p.m.