Learn R Programming

potts (version 0.5-11)

calc_t: Calculate Canonical Statistic for Potts Model

Description

Calculate the canonical statistic 't' for a realization of a Potts Model

Usage

calc_t_full(x,ncolor)
calc_t_innergrid(x, ncolor, grid, i, j)
calc_t(x, ncolor, grid=NULL, i=NULL, j=NULL)

Value

For a description of notation and terminology, see

composite.ll.

All functions return a vector of length ncolor+1. Elements 1,...,ncolor contain the number of pixels of each color. Element ncolor+1 contains the number of matching neighbor pairs for the image.

calc_t_full returns the values for the whole image.

calc_t_innergrid returns the value for just the selected window, but this includes the number of matching pairs from the replaced window to it's neighbors. E.g. if X is the full image, and \(A_a\) is the value of some window in the image and we want to know the value of \(t(y \cup X \setminus A_a)\) this would be calc_t_full(X, ncolor) + calc_t_innergrid(X, ncolor, y, i, j) - calc_t_innergrid(X, ncolor, A(a), i, j)

Arguments

x

2 dimensional matrix, elements in 1, ..., ncolor, representing a Potts model

ncolor

numeric. Number of colors in this Potts Model.

grid

numeric. 2 dimensional matrix, elements in 1, ..., ncolor. If non-NULL it is placed into x at the location x[i,j].

i

numeric. Row to place the grid.

j

numeric. Column to place the grid.

Details

For a description of notation and terminology, see composite.ll.

Calculates the canonical statistics for a realized Potts Model. calc_t calls calc_t_full if grid is NULL and calc_t_innergrid otherwise.

calc_t_full calculates the canonical statistics for the full image.

calc_t_innergrid calculates the canonical statistics for the a window of the image, but with that window replaced by grid, with the upper left corner of grid located at x[i,j].

See Also

generate_t_cache, composite.ll.

Examples

Run this code

ncolor <- 4
beta   <- log(1+sqrt(ncolor))
theta  <- c(rep(0,ncolor), beta)

nrow <- 32
ncol <- 32

x <- matrix(sample(ncolor, nrow*ncol, replace=TRUE), nrow=nrow, ncol=ncol)
foo <- packPotts(x, ncolor)
out <- potts(foo, theta, nbatch=10)
x <- unpackPotts(out$final)

t_stat <- calc_t(x, ncolor)
t_stat_inner <- calc_t(x, ncolor, matrix(1, nrow=2, ncol=2), 1, 1)

Run the code above in your browser using DataLab