Question: Any suggestions on calculating the expectation and variance of BW
joins on a raster/matrix where edge effects are not treated as a nuisance
but rather are included in the calculation?

Background:

Let's say I have a raster (or matrix) that is NxN cells. The cells take on
values of 0 or 1 (W or B).

The outer edge of this raster (cell[ ,1] or cell [ ,N] or cell [1, ] or
cell [N, ]) can be 0s or 1s.  Let's say for argument that the edge as
defined is composed of all 1 values and this is known a prior and does not
change.

Now, the interior of the raster (all cells not part of edge) take on values
of 0 or 1 with a certain probability(cell=1)=[whatever value is most
appropriate in the context].

I would like to know the expected value for 1-0 (or BW) joins over the
entire NxN raster given that the edge is set and joins with the edges
"count" toward the final tally of BW joins but the interior cells are 1s
(or black) with a certain probability.  Also, I would like to know the
variance of BW joins over the entire NxN raster given these same conditions.

I am interested because the "edge" in this analysis represents a previous
landscape and I would like to know what the future can hold given previous
conditions (the "memory" or "hysteresis" of the landscape going into the
future).

I am flexible on whether free sampling or non-free sampling is assumed,
with a guess that free sampling will be more tractable.  Also, for
simplicity, I would stick with rook case joins and only first neighbors
(directly adjacent cells).

I have searched for a function that computes join counts while taking into
account edge effects, but have come up empty handed.

I have looked at how expectations of BW joins and the variances are
computed, and I believe another day of work will result in code where I can
get the expectation under free sampling while taking into account the edge.
 That is because the expectation calculation is rather straightforward.
 However, I do not understand the variance calculation well enough to know
how to proceed on it.

Any input is appreciated.

Seth Myers

	[[alternative HTML version deleted]]

