Pebble transfer.py

From Werner KRAUTH

Jump to: navigation, search

This page presents the program pebble_transfer.py, a simple linear algebra algorithm for multifplying a probability vector with a transfer matrix.


Contents

Description

Program

import numpy

neighbor =  [[1, 3, 0, 0], [2, 4, 0, 1], [2, 5, 1, 2],
             [4, 6, 3, 0], [5, 7, 3, 1], [5, 8, 4, 2],
             [7, 6, 6, 3], [8, 7, 6, 4], [8, 8, 7, 5]]
transfer = numpy.zeros((9, 9))
for k in range(9):
    for neigh in range(4): transfer[neighbor[k][neigh], k] += 0.25
position = numpy.zeros(9)
position[8] = 1.0
for t in range(100):
    print t,'  ',["%0.5f" % i for i in position]
    position = numpy.dot(transfer, position)

Version

See history for version information.

Personal tools