Wednesday, September 17, 2008

Revamped Perl Script To More Evenly Distribute Number Pool Match Odds

Hey There,

It's been noted (and I know that it's true) that the spread-system used in the last portion of our Perl script (posted yesterday in our entry regarding maximizing guaranteed matches) was somewhat uneven. The end result, of course, being that your given set-numbers from pool-numbers (3 from 5, 4 from 6, etc) guaranteed that the sets would be included in the generated pools, but (as was noticed by a few people, including myself) the downside (?) ends up being that the front-numbers are more heavily weighted. That is to say that, given a situation where you've got 6 balls drawn, you want to guarantee matches of 3 and you're using a number pool of 8 different numbers (1, 2, 3, 4, 5, 6, 7 and 8 - for example), the first 3 return a higher percentage of the time than the numbers at the other end of the spectrum.

I actually chose to go with this sort of distribution for a particular reason. Well, reasoning, anyway. My reasoning was this: If I rewrite the distribution so that it ends up being more "fair" (The best I could get was a somewhat even distribution that would guarantee any given match set would come up only once or twice), this would probably seem like a better deal, since the odds are "spread out." This is where I, possibly, view things a little bit differently. In our original setup, even though the front numbers are more heavily weighted, the end numbers are guaranteed to contain match sets that all come up at least once or twice. Really, you've got the same thing as the more "fair" method, except for two strong distinctions (aside from the fact that the distributions are unequal in comparative outcomes):

1. In the "fair" distribution, your end number matched-sets have approximately the same odds of returning as they do in the "unfair" distribution. In the "fair" distribution, your end numbers tend to go back and forth between 1 and 2 match-sets guaranteed. In the "unfair" distribution, your end numbers are almost always going to be only 1 match set guaranteed. In neither case should you ever be getting back 0 match sets.

2. In the "fair" distribution, your front number matched-sets have the same odds of returning as your end number matched sets (1, and no more than 2 times guaranteed). In the "unfair" distribution, you'll find several match sets that will return matched sets over 10 times, and then a few more at 9 and some more at 8, a good amount of 4's and 3's and then down to 1's. Basically, your front numbers will be weighted to match not "more often," but "more heavily" if they do hit.

The heavy distribution differential can be easily drawn out, like this (using currency as the currency ;):

a. Front numbers.

1. Fair distribution: Matched set 123 is drawn. We match it twice. Each payout on a matched set it 5 dollars. We've made 10 dollars.
2. Unfair distribution: Matched set 123 is drawn. We match it 11 times. Each payout on a matched set is 5 dollars. We've made 55 dollars.

b. End numbers

1. Fair distribution: Matched set 789 is drawn. We may match it twice (rather than just once). Each payout on a matched set it 5 dollars. We've made 10 dollars.
2. Unfair distribution: Matched set 789 is drawn. We match it once. Each payout on a matched set it 5 dollars. We've made 5 dollars.

So, yes, I have to agree that a difference does exist (and would actually love to find the most economic way to make both ends of the distribution weigh in at 8 to 11 returns without having to run up too many combinations (At a certain point your expenses outweigh your gains... not to mention that those gains are only "possible" and not real until you, maybe, get lucky ;)

Although we went over this previously, I'll repost some data, with slight variations, so that the full code for both the "fair" and "unfair" distributions are covered.

Enjoy :)



FAIR:


@ball_draw_pool = qw(12345 12346 12347 12348 12356 12357 12358 12367 12368 12378 12456 12457 12458 12467 12468 12478 12567 12568 12578 12678 13456 13457 13458 13467 13468 13478 13567 13568 13578 13678 14567 14568 14578 14678 15678 23456 23457 23458 23467 23468 23478 23567 23568 23578 23678 24567 24568 24578 24678 25678 34567 34568 34578 34678 35678 45678);
@rev_ball_draw_pool = qw(45678 35678 34678 34578 34568 34567 25678 24678 24578 24568 24567 23678 23578 23568 23567 23478 23468 23467 23458 23457 23456 15678 14678 14578 14568 14567 13678 13578 13568 13567 13478 13468 13467 13458 13457 13456 12678 12578 12568 12567 12478 12468 12467 12458 12457 12456 12378 12368 12367 12358 12357 12356 12348 12347 12346 12345);

@ball_trap_pool = qw(123 124 125 126 127 128 134 135 136 137 138 145 146 147 148 156 157 158 167 168 178 234 235 236 237 238 245 246 247 248 256 257 258 267 268 278 345 346 347 348 356 357 358 367 368 378 456 457 458 467 468 478 567 568 578
678);

foreach $smaller (@ball_trap_pool) {
@smaller = split("",$smaller);
foreach $larger (@ball_draw_pool) {
print "$larger =~ $smaller[0] && $larger =~ $smaller[1] && $larger =~ $smaller[2]\n";
if ( $larger =~ $smaller[0] && $larger =~ $smaller[1] && $larger =~ $smaller[2] ) {
$total_pool{$larger} .= $smaller;
last;
$|=1;
}
}
}
foreach $smaller (@ball_trap_pool) {
@smaller = split("",$smaller);
foreach $larger (@rev_ball_draw_pool) {
print "$larger =~ $smaller[0] && $larger =~ $smaller[1] && $larger =~ $smaller[2]\n";
if ( $larger =~ $smaller[0] && $larger =~ $smaller[1] && $larger =~ $smaller[2] ) {
$total_pool{$larger} .= $smaller;
last;
$|=1;
}
}
}
$counter = 1;
foreach $key (sort keys %total_pool ) {
$total_poolkey = length $total_pool{$key};
if ( $total_poolkey <= 6 ) {
next;
}
print "Game $counter: $key -- $total_pool{$key}\n";
$counter++;
}



UNFAIR


@ball_draw_pool = qw(12345 12346 12347 12348 12356 12357 12358 12367 12368 12378 12456 12457 12458 12467 12468 12478 12567 12568 12578 12678 13456 13457 13458 13467 13468 13478 13567 13568 13578 13678 14567 14568 14578 14678 15678 23456 23457 23458 23467 23468 23478 23567 23568 23578 23678 24567 24568 24578 24678 25678 34567 34568 34578 34678 35678 45678);

@ball_trap_pool = qw(123 124 125 126 127 128 134 135 136 137 138 145 146 147 148 156 157 158 167 168 178 234 235 236 237 238 245 246 247 248 256 257 258 267 268 278 345 346 347 348 356 357 358 367 368 378 456 457 458 467 468 478 567 568 578 678);

foreach $smaller (@ball_trap_pool) {
@smaller = split("",$smaller);
foreach $larger (@ball_draw_pool) {
print "$larger =~ $smaller[0] && $larger =~ $smaller[1] && $larger =~ $smaller[2]\n";
if ( $larger =~ $smaller[0] && $larger =~ $smaller[1] && $larger =~ $smaller[2] ) {
$total_pool{$larger} .= $smaller;
last;
$|=1;
}
}
}
$counter = 1;
foreach $key (sort keys %total_pool ) {
$total_poolkey = length $total_pool{$key};
if ( $total_poolkey <= 6 ) {
next;
}
print "Game $counter: $key -- $total_pool{$key}\n";
$counter++;
}


, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.