Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -1,8 +1,8 @@
|
|||
# --- with command line argument "throws" ---
|
||||
|
||||
BEGIN{ th=ARGV[1];
|
||||
for(i=0; i<th; i++) cin += (rand()**2 + rand()**2) < 1 ;
|
||||
printf("Pi = %8.5f\n",4*cin/th);
|
||||
for(i=0; i<th; i++) cin += (rand()^2 + rand()^2) < 1
|
||||
printf("Pi = %8.5f\n",4*cin/th)
|
||||
}
|
||||
|
||||
usage: awk -f pi 2300
|
||||
|
|
|
|||
7
Task/Monte-Carlo-methods/Julia/monte-carlo-methods.julia
Normal file
7
Task/Monte-Carlo-methods/Julia/monte-carlo-methods.julia
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function montepi(n)
|
||||
s = 0
|
||||
for i = 1:n
|
||||
s += rand()^2 + rand()^2 < 1
|
||||
end
|
||||
return 4*s/n
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue