Skip to content

Instantly share code, notes, and snippets.

View edxu96's full-sized avatar

Edward Xu edxu96

View GitHub Profile
@edxu96
edxu96 / A-2D-Random-Walk.md
Last active June 28, 2019 20:23
Array the 2-D Irregular Sample Space for 8-Direction Random Walk

A 2D Random Walk: Array the 2-D Irregular Sample Space for 8-Direction Random Walk

If the 2-D sample space is not regular, it may cause asymmetry in probability during a random walk. This algorithm rearranges the sample space to a new array with nRow rows and nCol columns.

How it Works

m = 2;
funcLogic = @(data1, data2) ((0 <= data1 + data2) & (data1 + data2 <= m));