Show relevant Perl code
$POP = 1000; $R = 1000; $X = 1; $SIM = 100; $POPD = $POP/(4*$R*$R); for ($i=0;$i<$SIM;$i++) { # Generate population within square of sides $R*2 for ($j=0;$j<$POP;$j++) { $x = rand()*($R*2)-$R; $y = rand()*($R*2)-$R; $d = sqrt($x*$x+$y*$y); $POSX[$j] = $x; $POSY[$j] = $y; $POSD[$j] = $d; } @POSA = sort {$a <=> $b} @POSD; # By right shouldn't, but should be ok for reasonably large $POP and not incredibly small $X $SIMA[$i] = $R; for ($j=0;$j<$POP;$j++) { if (rand() >= (1-$X)) { $SIMA[$i] = $POSA[$j]; $i2 = $i+1; last; } } $j++; } } |