Percolation/Site percolation/J: Difference between revisions
Content added Content deleted
mNo edit summary |
m (flesh out examples a bit) |
||
Line 33: | Line 33: | ||
2 0 2 0 1 0 1 0 0 1 1 1 1 1 0 ([ >. [ +&* [ * [: ; groups@[ <@(* * 2 < >./)/. +) 0 0 1 1 1 1 0 2 0 2 0 1 1 1 1 |
2 0 2 0 1 0 1 0 0 1 1 1 1 1 0 ([ >. [ +&* [ * [: ; groups@[ <@(* * 2 < >./)/. +) 0 0 1 1 1 1 0 2 0 2 0 1 1 1 1 |
||
2 0 2 0 1 0 1 0 0 2 2 2 2 2 0</lang> |
2 0 2 0 1 0 1 0 0 2 2 2 2 2 0</lang> |
||
Note that u/. uses the key in the left argument to gather corresponding values from the right argument (which are then processed by <code>u</code>). |
|||
<lang j> 2 0 2 0 1 0 1 0 0 1 1 1 1 1 0 (groups@[ </. +) 0 0 1 1 1 1 0 2 0 2 0 1 1 1 1 |
|||
┌───┬───┬───┬─────┬───────────┐ |
|||
│2 0│3 1│2 1│1 2 0│3 1 2 2 2 1│ |
|||
└───┴───┴───┴─────┴───────────┘ |
|||
2 0 2 0 1 0 1 0 0 1 1 1 1 1 0 (groups@[ <@(>./)/. +) 0 0 1 1 1 1 0 2 0 2 0 1 1 1 1 |
|||
┌─┬─┬─┬─┬─┐ |
|||
│2│3│2│2│3│ |
|||
└─┴─┴─┴─┴─┘ |
|||
2 0 2 0 1 0 1 0 0 1 1 1 1 1 0 (groups@[ <@(2 < >./)/. +) 0 0 1 1 1 1 0 2 0 2 0 1 1 1 1 |
|||
┌─┬─┬─┬─┬─┐ |
|||
│0│1│0│0│1│ |
|||
└─┴─┴─┴─┴─┘ |
|||
2 0 2 0 1 0 1 0 0 1 1 1 1 1 0 (groups@[ <@(* * 2 < >./)/. +) 0 0 1 1 1 1 0 2 0 2 0 1 1 1 1 |
|||
┌───┬───┬───┬─────┬───────────┐ |
|||
│0 0│1 1│0 0│0 0 0│1 1 1 1 1 1│ |
|||
└───┴───┴───┴─────┴───────────┘</lang> |
|||
We use +&* because 1 +&* 2 is 2, but also 2 +&* 2 is 2: |
We use +&* because 1 +&* 2 is 2, but also 2 +&* 2 is 2: |
||
Line 231: | Line 250: | ||
1 1 0 1 0 1 1 1 1 1 1 0 1 1 0 |
1 1 0 1 0 1 1 1 1 1 1 0 1 1 0 |
||
0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 |
0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 |
||
1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 |
1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 |
||
0.6 percolate@([ >: ] ?@$ 0:) 15 15 |
|||
0 0 0 0 2 2 2 2 2 0 2 0 0 0 2 |
|||
0 1 0 2 0 2 2 0 2 0 2 2 0 0 0 |
|||
1 0 2 2 2 2 2 2 2 0 0 2 0 0 1 |
|||
0 2 2 0 2 0 2 0 2 0 2 2 2 0 1 |
|||
2 2 2 2 0 2 2 2 2 0 2 2 0 0 1 |
|||
2 2 2 0 1 0 2 2 0 0 2 2 2 2 0 |
|||
0 0 2 2 0 0 2 2 2 0 2 2 0 2 2 |
|||
0 2 2 0 0 2 2 2 2 2 0 2 2 0 2 |
|||
0 2 0 0 0 2 0 0 0 0 0 2 2 0 0 |
|||
0 2 0 2 2 2 2 0 2 2 2 2 0 0 0 |
|||
0 2 2 2 2 2 0 0 2 2 2 0 1 0 2 |
|||
2 0 2 0 0 0 2 2 0 0 0 0 0 0 2 |
|||
2 2 2 2 2 2 2 2 2 2 2 2 0 2 2 |
|||
0 0 2 2 2 2 0 2 2 0 0 2 2 2 0 |
|||
0 1 0 0 2 0 2 2 0 0 1 0 2 0 1</lang> |
|||
<code>simulate</code> runs a sequence of 15 by 15 trials and averages them. Since each trial is different, each run of simulate is different. |
<code>simulate</code> runs a sequence of 15 by 15 trials and averages them. Since each trial is different, each run of simulate is different. |