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.


In reply to Re^3: Calculate propabilities without recursion? Coin toss. by roboticus
in thread Calculate propabilities without recursion? Coin toss. by Microcebus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.