View source: R/importance_sampling_functions.R
initialise_particle_sets | R Documentation |
Function to initialise particle sets from a list of samples
initialise_particle_sets(samples_to_fuse, multivariate, number_of_steps = 2)
samples_to_fuse |
a list of samples that you wish to perform fusion with |
multivariate |
logical value indicating if the samples are multivariate (TRUE) or not (FALSE) |
number_of_steps |
integer value for number of steps in the Fusion algorithm (default is 2 for Monte Carlo Fusion) |
A list of particles to fuse, where the cth component is the particle for sub-posterior c. In particular, each item in the list is an environment with components
samples for y in particle set (initialised as the samples given)
a list where x_samples[[i]] is the ith x sample for in particle set (all initialised as NA)
the corresponding means for x_samples (initialised as NA)
associated logarithm of the weights (initialised as the logarithm of 1/number of samples)
associated normalised weights (initialised as 1/number of samples)
effective sample size of particles (initialised as the number of samples)
conditional effective sample size of particles after each step of the algorithm (initialised as NA for each step)
logical value to indicate if particles have been resampled after each step (initialised as FALSE for each step besides the last step, which is set to TRUE)
number of steps in the Fusion algorithm (initialised as the number_of_steps provided)
Number of particles
# univariate uni_samples <- lapply(1:2, function(i) rnorm(100, 0, 1)) particles <- initialise_particle_sets(samples_to_fuse = uni_samples, multivariate = FALSE) # multivariate multi_samples <- lapply(1:2, function(i) mvrnormArma(100, c(0, 0), diag(2))) particles <- initialise_particle_sets(samples_to_fuse = multi_samples, multivariate = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.