weighted_trajectory_variation_univariate: Calculate approximation to expectation of nu_j (univariate)

View source: R/RcppExports.R

weighted_trajectory_variation_univariateR Documentation

Calculate approximation to expectation of nu_j (univariate)

Description

Calculation of the scaled/weighted average variation of the C trajectories with respect to their individual sub-posterior means

Usage

weighted_trajectory_variation_univariate(
  x_samples,
  normalised_weights,
  sub_posterior_means,
  precondition_values
)

Arguments

sub_posterior_means

vector of length C of sub-posterior means

precondition_values

precondition values associated to each sub-posterior

list

where x_samples[[i]] ith collection of the C trajectories

Value

the approximated expectation of nu_j

Examples

# x_samples has 5 samples and C=4
N <- 10
C <- 4
x_samples <- lapply(1:N, function(i) rnorm(C))
normalised_weights <- rep(1/N, N)
sub_posterior_means <- rnorm(C)
precond <- 1:C
weighted_trajectory_variation_univariate(x_samples = x_samples,
                                         normalised_weights = normalised_weights,
                                         sub_posterior_means = sub_posterior_means,
                                         precondition_values = precond)
# should be equal to the result of this:
sum(sapply(1:N, function(i) {
  sum((((x_samples[[i]]-sub_posterior_means)^2)/precond))/C
}))/N

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