Description Usage Arguments Details Value Examples
Draw a sample from a Potts model. Call the simulPotts_cpp
or the simulPottsFast_cpp
C++ function.
1 2 | simulPotts(W, G, rho, initialization = NULL, site_order = NULL, iter_max = 2500,
cv.criterion = 0, fast = FALSE, verbose = TRUE)
|
W |
the neighbourhood matrix. dgCMatrix. Should be normalized by row (i.e. |
G |
the number of groups. postive integer. REQUIRED. |
rho |
the value of the regularization parameter (also called potts parameter or inverse temperature). REQUIRED. |
initialization |
the probability membership of each voxel to each group used for initialisation. matrix. |
site_order |
a specific order to go all over the sites. Can be |
iter_max |
the number of iterations. numeric. |
cv.criterion |
maximum difference in group probability membership for convergence ? double between 0 and 1. |
fast |
should |
verbose |
should the simulation be be traced over iterations ? logical. |
If no specific order is set, the order is sampled in a uniformed law which increase the computation time.
If site_order
is set to true, independant spatial block are identifyied using the calcBlockW
function.
Each independant spatial block is then iteratively considered.
A numeric vector containing the regional potential.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # spatial field
## Not run:
n <- 30
iter_max <- 500
## End(Not run)
G <- 3
coords <- data.frame(which(matrix(0, nrow = n * G, ncol = n * G) == 0, arr.ind = TRUE), 1)
optionsMRIaggr(quantiles.legend = FALSE, axes = FALSE, num.main = FALSE)
# neighbourhood matrix
resW <- calcW(coords, range = sqrt(2), row.norm = TRUE, calcBlockW = TRUE)
W <- resW$W
# with no initial sample
res1 <- simulPotts(W, G = 3, rho = 3, iter_max = iter_max)
multiplot(coords,
apply(res1$simulation, 1, which.max),
breaks=seq(0.5, 3.5, 1))
res2 <- simulPotts(W, G = 4, rho = 3, iter_max = iter_max)
multiplot(coords,
apply(res2$simulation, 1, which.max),
breaks = seq(0.5, 4.5, 1))
res3 <- simulPotts(W, G = 4, rho = 6, iter_max = iter_max)
multiplot(coords,
apply(res3$simulation, 1, which.max),
breaks = seq(0.5, 4.5, 1))
# with specific initialisation
res3.bis <- simulPotts(W, rho = 6, initialization = res3$simulation, iter_max = iter_max / 2)
multiplot(coords,
apply(res3.bis$simulation, 1, which.max),
breaks=seq(0.5, 4.5, 1))
res3.ter <- simulPotts(W, rho = 6, initialization = res3$simulation, iter_max = iter_max)
multiplot(coords,
apply(res3.ter$simulation, 1, which.max),
breaks=seq(0.5, 4.5, 1))
#### defining site order save time
site_order <- unlist(resW$blocks$ls_groups) - 1
system.time(
res <- simulPotts(W, iter_max = 100, G = 3, rho = 6, site_order = NULL,
fast = TRUE, verbose = FALSE)
)
system.time(
res <- simulPotts(W, iter_max = 100, G = 3, rho = 6, site_order = site_order,
fast = TRUE, verbose = FALSE)
)
system.time(
res <- simulPotts(W, iter_max = 100, G = 3, rho = 6, site_order = NULL,
fast = FALSE, verbose = FALSE)
)
system.time(
res <- simulPotts(W, iter_max = 100, G = 3, rho = 6, site_order = site_order,
fast = FALSE, verbose = FALSE)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.