Skip to content

Instantly share code, notes, and snippets.

@santhoshtr
Created February 13, 2026 10:04
Show Gist options
  • Select an option

  • Save santhoshtr/afcf71ff2ee1715cd3f0bb7cc62e1215 to your computer and use it in GitHub Desktop.

Select an option

Save santhoshtr/afcf71ff2ee1715cd3f0bb7cc62e1215 to your computer and use it in GitHub Desktop.
Brownian motion #metapost-sandbox
beginfig(1);
% randomseed := uniformdeviate infinity;
randomseed := 2141.34242;
numeric u, v; u = 5; v = 4;
for n=1 upto 4:
numeric x, y; x = y = 0;
path w; w = (x, y) for i=1 upto 2048:
hide(x := x + normaldeviate * u ; y := y + normaldeviate * v)
.. (x, y)
endfor;
draw w withcolor (2n/10)[white, 2/3 blue];
draw (x, y) withpen pencircle scaled 3 withcolor 2/3 red;
endfor
draw origin withpen pencircle scaled 3 withcolor 3/4 green;
endfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment