Run a sequential Gibbs sampler to sample spatial data given a lattice and neighborhood structure.
1 2 3 4 5 6 7 | run_sequential_gibbs(
neighbors,
inits,
conditional_sampler,
params,
n_iter = 100L
)
|
neighbors |
A matrix N*N by (max // neighbors) + 1, where the first column is the location id of each location in the lattice. This could be the result from get_neighbors(). If NULL, will be calculated within the function. |
inits |
Initial values for the lattice, formatted as a grid. |
conditional_sampler |
The string name of a function that has two inputs:
There are three built in samplers:
If the user chooses to write their own sampler in R, they must pass the name of the sampler that is available in the gloabl environment as this parameter. The input "data" is a list containing two elements, sums and nums which contain the sum of the data in each neighborhood as well as the number of locations in the neighborhood for each point in the conclique. The input "params" is a list of parameter values. This function returns a value sampled from the specified conditional distribution given the data and parameters passed. |
params |
A list of parameters to be passed to the conditional_sampler function |
n_iter |
Number of times to run the Gibbs sampler |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.