resample_particle_x_samples: Resampling a particle set for x

View source: R/importance_sampling_functions.R

resample_particle_x_samplesR Documentation

Resampling a particle set for x

Description

Resamples the particle set for the samples for x

Usage

resample_particle_x_samples(
  N = particle_set$N,
  particle_set,
  multivariate,
  step = 1,
  resampling_method = "multi",
  seed = NULL
)

Arguments

N

number of samples (default is particle_set$N)

particle_set

particle object (see initialise_particle_set)

multivariate

logical value indicating if the particles are multivariate (TRUE) or not (FALSE)

step

the step of the algorithm is this is resampling for

resampling_method

method to be used in resampling, default is multinomial resampling ('multi'). Other choices are stratified resampling ('strat'), systematic resampling ('system'), residual resampling ('resid')

seed

seed number - default is NULL, meaning there is no seed

Value

resampled particle set. Returns the same set if it has already been resampled

Examples

samples_to_fuse <- lapply(1:2, function(i) rnorm(100, 0, 1))
particles_to_fuse <- initialise_particle_sets(samples_to_fuse = samples_to_fuse,
                                              multivariate = FALSE)
precondition_values <- sapply(samples_to_fuse, var)
particles <- rho_IS_univariate(particles_to_fuse = particles_to_fuse,
                               N = 100,
                               m = 2,
                               time = 0.5,
                               precondition_values = precondition_values)
particles <- resample_particle_x_samples(particle_set = particles,
                                         multivariate = FALSE,
                                         resampling_method = 'resid',
                                         seed = 21)


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