Created
February 13, 2026 10:04
-
-
Save santhoshtr/afcf71ff2ee1715cd3f0bb7cc62e1215 to your computer and use it in GitHub Desktop.
Brownian motion #metapost-sandbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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