CR_indexmatching_given: Coupled Resampling: index-matching, given vector of ancestor

Description Usage Details Value

Description

This function performs index-matching resampling on the second system

Usage

1
2
CR_indexmatching_given(xparticles1, xparticles2, normweights1, normweights2,
  parameters = list(), ancestors_ref, uniforms)

Details

#' @export CR_indexmatching_given <- function(xparticles1, xparticles2, normweights1, normweights2, parameters = list(), ancestors_ref, uniforms) nparticles <- length(normweights1) # common measure nu <- pmin(normweights1, normweights2) alpha <- sum(nu) # check if the weight vectors are equal, in which case we don't need to sweat too much if (alpha > 1-1e-20) ancestors2 <- ancestors_ref return(ancestors2) mu <- nu / alpha # residuals R1 <- normweights1 - nu R1 <- R1 / (1 - alpha)

R2 <- normweights2 - nu R2 <- R2 / (1 - alpha)

P <- diag(nu, nparticles, nparticles) + (1-alpha)* matrix(R1, ncol = 1) # print(P) ancestors2 <- rep(0, nparticles) for (i in 1:nparticles) ancestors2[i] <- sample(1:nparticles, 1, replace = TRUE, prob = P[ancestors_ref[i],]) # return(ancestors2)

Value

A vector of ancestors


pierrejacob/CoupledPF documentation built on May 25, 2019, 6:07 a.m.