lecture code viewer
downloads
Code
Generating Randomness
Generating Randomness
Martin Krzywinski
#!/usr/local/bin/perl
use strict;
use constant PI => 3.1415926535897932;
use Math::VecStat qw(average);
$\="\n";
$,=" ";
my $iter = 10;
for my $j (1..7) {
my @pi;
for my $iter (0..$iter-1) {
my $c;
for (0..10**$j) {
my ($x,$y) = (rand(),rand());
my $d = (0.5-$x)*(0.5-$x) + (0.5-$y)*(0.5-$y);
my $dt = int ($d < 0.25);
$c ++ if $dt;
}
my $pi = 4*$c/10**$j;
push(@pi,$pi);
print "value",10**$j,$pi;
}
print "average",10**$j,average(@pi);
print "diff",10**$j,abs(average(@pi) - PI)/PI;
}
|
1 |
Generating Randomness |
4.1.2.2.1
4.1.2.2.1.c1 |
brownnoise.wav
|
Martin Krzywinski
|
code
4.1.2.2.1.c2 |
devrandom
|
Martin Krzywinski
|
code
4.1.2.2.1.c3 |
drophaltonrice
|
Martin Krzywinski
|
code
4.1.2.2.1.c4 |
droprice
|
Martin Krzywinski
|
code
4.1.2.2.1.c5 |
halton
|
Martin Krzywinski
|
code
4.1.2.2.1.c6 |
halton.11.13.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c7 |
halton.3.5.1000.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c8 |
halton.3.5.10000.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c9 |
halton.3.5.200.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c10 |
halton.3.5.2000.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c11 |
halton.3.5.400.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c12 |
halton.3.5.4000.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c13 |
halton.3.5.600.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c14 |
halton.3.5.800.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c15 |
halton.3.5.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c16 |
halton.5.7.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c17 |
halton.7.17.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c18 |
halton.new.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c19 |
haltonrice.diff.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c20 |
haltonrice.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c21 |
pinknoise.wav
|
Martin Krzywinski
|
code
4.1.2.2.1.c22 |
prng
|
Martin Krzywinski
|
code
4.1.2.2.1.c23 |
prng.1.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c24 |
prng.2.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c25 |
prng.3.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c26 |
randbase
|
Martin Krzywinski
|
code
4.1.2.2.1.c27 |
randrice.diff.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c28 |
randrice.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c29 |
randstring
|
Martin Krzywinski
|
code
4.1.2.2.1.c30 |
randtests
|
Martin Krzywinski
|
code
4.1.2.2.1.c31 |
rice.diff.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c32 |
rice.results.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c33 |
rice.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c34 |
rice.value.txt
|
Martin Krzywinski
|
code
4.1.2.2.1.c35 |
shake
|
Martin Krzywinski
|
code
4.1.2.2.1.c36 |
trulyrandom
|
Martin Krzywinski
|
code
4.1.2.2.1.c37 |
whitenoise.wav
|
Martin Krzywinski
|
code
4.1.2.2.1.a1 |
Generating Randomness
|
Martin Krzywinski
|
pdf
4.1.2.2.1.p1 |
Generating Randomness
|
Martin Krzywinski
|
ppt
4.1.2.2.1.s1 |
Generating Randomness
|
Martin Krzywinski
|
slides
|