Microcebus:
If you want to approach it analytically:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $num_dice = 5;
my @probabilities = ( 0.05, 0.10, 0.20, 0.30, 0.35 );
my @values = ( 1, 5, 7, 13, 17 );
my $throw_die_ntimes = 5;
my @possibilities = ();
my $it = combo($num_dice, 0 .. $num_dice-1);
while (my $t = &$it()) {
$possibilities[ttl($t)] += prob($t);
}
my $cum=0;
for my $ttl (0 .. $#possibilities) {
next if ! defined $possibilities[$ttl];
$cum += $possibilities[$ttl];
printf "% 5u prob=%.8f, prob<=:%.8f, prob>:%.8f\n",
$ttl, $possibilities[$ttl], $cum, 1-$cum;
}
sub prob {
my $prob=1;
$prob *= $probabilities[$_] for @{$_[0]};
return $prob;
}
sub ttl {
my $total=0;
$total += $values[$_] for @{$_[0]};
return $total;
}
sub combo {
my ($num_dice, @list) = @_;
my @position = ($#list) x $num_dice;
my $done_fl = 0;
# Since we pre-decrement, adjust so we return proper item on first
+ pass
$position[0]++;
return sub {
return undef if $done_fl;
my $cur = 0;
{
if (--$position[$cur] < 0) {
# reset current dig & try next one
$position[$cur] = $#list;
$cur++;
if ($cur > $num_dice) {
$done_fl=1;
return undef;
}
redo;
}
}
return [ @list[@position] ];
}
}
When run, I get:
$ perl 895892.pl
5 prob=0.00000031, prob<=:0.00000031, prob>:0.99999969
9 prob=0.00000313, prob<=:0.00000344, prob>:0.99999656
11 prob=0.00000625, prob<=:0.00000969, prob>:0.99999031
13 prob=0.00001250, prob<=:0.00002219, prob>:0.99997781
15 prob=0.00005000, prob<=:0.00007219, prob>:0.99992781
17 prob=0.00008438, prob<=:0.00015656, prob>:0.99984344
19 prob=0.00015000, prob<=:0.00030656, prob>:0.99969344
21 prob=0.00041094, prob<=:0.00071750, prob>:0.99928250
23 prob=0.00055000, prob<=:0.00126750, prob>:0.99873250
25 prob=0.00092250, prob<=:0.00219000, prob>:0.99781000
27 prob=0.00197500, prob<=:0.00416500, prob>:0.99583500
29 prob=0.00237500, prob<=:0.00654000, prob>:0.99346000
31 prob=0.00365000, prob<=:0.01019000, prob>:0.98981000
33 prob=0.00688750, prob<=:0.01707750, prob>:0.98292250
35 prob=0.00737000, prob<=:0.02444750, prob>:0.97555250
37 prob=0.01105313, prob<=:0.03550063, prob>:0.96449937
39 prob=0.01755000, prob<=:0.05305063, prob>:0.94694937
41 prob=0.01764375, prob<=:0.07069438, prob>:0.92930562
43 prob=0.02543750, prob<=:0.09613188, prob>:0.90386812
45 prob=0.03520000, prob<=:0.13133188, prob>:0.86866812
47 prob=0.03255000, prob<=:0.16388187, prob>:0.83611813
49 prob=0.04868125, prob<=:0.21256312, prob>:0.78743688
51 prob=0.05385000, prob<=:0.26641312, prob>:0.73358688
53 prob=0.04907188, prob<=:0.31548500, prob>:0.68451500
55 prob=0.06965000, prob<=:0.38513500, prob>:0.61486500
57 prob=0.06661250, prob<=:0.45174750, prob>:0.54825250
59 prob=0.06077500, prob<=:0.51252250, prob>:0.48747750
61 prob=0.08382500, prob<=:0.59634750, prob>:0.40365250
63 prob=0.05495000, prob<=:0.65129750, prob>:0.34870250
65 prob=0.06551750, prob<=:0.71681500, prob>:0.28318500
67 prob=0.06615000, prob<=:0.78296500, prob>:0.21703500
69 prob=0.04365156, prob<=:0.82661656, prob>:0.17338344
71 prob=0.05145000, prob<=:0.87806656, prob>:0.12193344
73 prob=0.04057812, prob<=:0.91864469, prob>:0.08135531
75 prob=0.01500625, prob<=:0.93365094, prob>:0.06634906
77 prob=0.03858750, prob<=:0.97223844, prob>:0.02776156
81 prob=0.02250937, prob<=:0.99474781, prob>:0.00525219
85 prob=0.00525219, prob<=:1.00000000, prob>:0.00000000
...roboticus
When your only tool is a hammer, all problems look like your thumb.