Microcebus:
As others have said, if you're a scientist, you should definitely find a programming language to become proficient at!
Anyway, here's a start. I don't know exactly what you're trying to do, so I just hacked together a couple things from the posts I cited in my previous response. Here ya go:
use strict;
use warnings;
use List::Util qw(reduce);
use bignum;
# Number of coins to toss
my $coin_toss=1000;
# We cumulative probability of side1 appearing anywhere between 1 and
+60 times
my $side1=60;
# Compute the binomial coefficients for row 1000 of pascal's triangle
my @triangle = robo_2(1000);
print <<EOHDR;
Tails Count %
----- ---------- ------
EOHDR
my $total_prob=0;
my $runs = reduce { $a + $b } @triangle;
for (my $i = 0; $i < @triangle; $i++) {
my $prob = $triangle[$i]/$runs;
$total_prob += $prob unless $i > $side1;
print "$i\t$triangle[$i]\t",100*$prob, "\n";
}
print "\n\nProbability of 0..60 tails is: ", $total_prob*100;
sub robo_2 {
my $row = shift;
my @cols = (1);
++$row;
$cols[$_] = $cols[$_-1] * ($row-$_)/$_ for 1 .. $row-1;
return @cols;
}
Note: The output gets pretty darned wide with 1000 tosses and bignum in the picture...
...roboticus
When your only tool is a hammer, all problems look like your thumb. |