Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Sleeping-Beauty-problem/Perl/sleeping-beauty-problem.pl
Normal file
12
Task/Sleeping-Beauty-problem/Perl/sleeping-beauty-problem.pl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub sleeping_beauty {
|
||||
my($trials) = @_;
|
||||
my($gotheadsonwaking,$wakenings);
|
||||
$wakenings++ and rand > .5 ? $gotheadsonwaking++ : $wakenings++ for 1..$trials;
|
||||
$wakenings, $gotheadsonwaking/$wakenings
|
||||
}
|
||||
|
||||
my $trials = 1_000_000;
|
||||
printf "Wakenings over $trials experiments: %d\nSleeping Beauty should estimate a credence of: %.4f\n", sleeping_beauty($trials);
|
||||
Loading…
Add table
Add a link
Reference in a new issue