Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
sub R {
|
||||
my ($n, $p) = @_;
|
||||
my $r = join '',
|
||||
map { rand() < $p ? 1 : 0 } 1 .. $n;
|
||||
0+ $r =~ s/1+//g;
|
||||
}
|
||||
|
||||
use constant t => 100;
|
||||
|
||||
printf "t= %d\n", t;
|
||||
for my $p (qw(.1 .3 .5 .7 .9)) {
|
||||
printf "p= %f, K(p)= %f\n", $p, $p*(1-$p);
|
||||
for my $n (qw(10 100 1000)) {
|
||||
my $r; $r += R($n, $p) for 1 .. t; $r /= $n;
|
||||
printf " R(n, p)= %f\n", $r / t;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue