Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Monte-Carlo-methods/Raku/monte-carlo-methods-1.raku
Normal file
9
Task/Monte-Carlo-methods/Raku/monte-carlo-methods-1.raku
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
my @random_distances = ([+] rand**2 xx 2) xx *;
|
||||
|
||||
sub approximate_pi(Int $n) {
|
||||
4 * @random_distances[^$n].grep(* < 1) / $n
|
||||
}
|
||||
|
||||
say "Monte-Carlo π approximation:";
|
||||
say "$_ iterations: ", approximate_pi $_
|
||||
for 100, 1_000, 10_000;
|
||||
2
Task/Monte-Carlo-methods/Raku/monte-carlo-methods-2.raku
Normal file
2
Task/Monte-Carlo-methods/Raku/monte-carlo-methods-2.raku
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
my @pi = ([\+] 4 * (1 > [+] rand**2 xx 2) xx *) Z/ 1 .. *;
|
||||
say @pi[10, 1000, 10_000];
|
||||
Loading…
Add table
Add a link
Reference in a new issue