Skip to contents

Simulating the walk would make the two language arms agree only in distribution. The transition law is linear, so the whole distribution is pushed forward exactly – same numbers in both arms and no Monte Carlo error.

Usage

Randwk(G, start = 1L, steps = 1L)

Arguments

G

Non-negative weight matrix with positive row sums.

start

Starting node, 1-based here; the Python arm takes it 0-based. Reported indices are 0-based in both arms.

steps

Number of steps, non-negative.

Value

List with p, estimate, argmax (0-based), p_start, n.

Details

Formula: P(j | i) = A_ij / k_i; the returned vector is e_start P^steps.

References

Lovasz, L. (1996). Random walks on graphs: a survey. In Combinatorics, Paul Erdos is Eighty, Vol. 2, pages 1-46, Janos Bolyai Mathematical Society, Budapest.

Examples

G <- matrix(c(0, 1, 1, 1, 0, 0, 1, 0, 0), 3)   # a star centred on node 1
Randwk(G, start = 1L, steps = 2L)$p
#> [1] 1 0 0