Anonymous user
Percolation/Mean run density: Difference between revisions
m
→{{header|J}}: Corrected missing factor of 100 in normal case of delta
(FORTRAN entry) |
m (→{{header|J}}: Corrected missing factor of 100 in normal case of delta) |
||
Line 297:
<lang J>
NB. translation of python
NB. 'N P T' =: 100 0.5 500 NB. silliness
newv =: (> ?@(#&0))~ NB. generate a random binary vector. Use: N newv P
runs =: {: + [: +/ 1 0&E. NB. add the tail to the sum of 1 0 occurrences Use: runs V
mean_run_density =: [ %~ [: runs newv NB. perform experiment. Use: N mean_run_density P
main =: 3 : 0 NB. Use: main T
T =. y
Line 312:
for_N. 2 ^ 10 + +: i. 3 do.
SIM =. T %~ +/ ".@:('N mean_run_density P'"_)^:(<T)0
smoutput 4 5j2 6 6j3 6j3 4j1 ": T, P, N, LIMIT, SIM, SIM (100 * [
end.
end.
Line 320:
Session:
<pre>
T P N P(1-P) SIM DELTA
500 0.10 1024 0.090 0.
500 0.10 4096 0.090 0.090 0.
500 0.10 16384 0.090 0.090 0.
500 0.30 1024 0.210 0.210 0.
500 0.30 4096 0.210 0.
500 0.30 16384 0.210 0.210 0.
500 0.50 1024 0.250 0.250 0.
500 0.50 4096 0.250 0.250 0.
500 0.50 16384 0.250 0.250 0.
500 0.70 1024 0.210 0.210 0.0
500 0.70 4096 0.210 0.210 0.
500 0.70 16384 0.210 0.210 0.
500 0.90 1024 0.090 0.091
500 0.90 4096 0.090 0.090 0.
500 0.90 16384 0.090 0.090 0.
</pre>
|