There's nothing wrong with estimating p-values using Monte Carlo simulations. There is, however, something wrong with estimating p-values using Monte Carlo simulations in Excel. It's hard on the soul.
Here's a very simple Monte Carlo script coded in Perl. (You can download a free copy of Perl from http://www.activeperl.com/.) On a decent machine you should easily be able to run 2,000,000 55-bet trials in a minute or less. You should modify the EDGE, TRIALS, and BOGEY constants to suit your needs.
Do you have any code you would be willing to part with that permits weights? For example, I currently generate a positive edge prediction for each of the decimal odds.
+120 .0645544
-110 .0323433
etc.
These would be my full edge expectations at 95% confidence level. I would then bet the percentage required to win that edge. In practice, I bet 1/4 Kelly (i.e. .065544 / 4). So, I know what the total Bogey results are for the sample assuming 1 /4 Kelly (or whatever percentage I like) and would like to calculate the probability that the Bogey result I obtained from the weighted bets was by chance.
Location: Forest Hills, NY, Home of the Blitzkrieg Bop
Posts: 4,631
Quote:
Originally Posted by VideoReview
Do you have any code you would be willing to part with that permits weights? For example, I currently generate a positive edge prediction for each of the decimal odds.
+120 .0645544
-110 .0323433
etc.
These would be my full edge expectations at 95% confidence level. I would then bet the percentage required to win that edge. In practice, I bet 1/4 Kelly (i.e. .065544 / 4). So, I know what the total Bogey results are for the sample assuming 1 /4 Kelly (or whatever percentage I like) and would like to calculate the probability that the Bogey result I obtained from the weighted bets was by chance.
Thanks Ganchrow.
First off and for whatever it's worth, while betting to win 1/4 edge is typically a very accurate approximation to quarter-Kelly it isn't really quarter-Kelly. The exact formula for single-bet quarter-Kelly would be:
K¼ = ( (wp)0.25 - (1 - p)0.25 ) / ((wp)0.25 + w * (1 - p)0.25) if > 0
And for n-Kelly:
Kn = ( (wp)n - (1 - p)n ) / ((wp)n + w * (1 - p)n) if > 0
I have to say that you're probably best off learning a bit of a Perl so you can tailor the above program to your own personal needs (or redoing the entire program in a language with which you already comfortable. As I'm sure you can understand I don't rea;ly want to get into the habit of programming-on-demand for every poster that asks.
Now that said, because I've been so remiss in getting back to you on your other questions that I feel kind oif guilty. So here's how I'd modify the montecarlo.pl script to permit bet sizing specifications in your input file.
Code:
#!perl
# Author: ganchrow@sbrforum.com
# a very simple implementation of the
# Monte Carlo method in fixed odds
# sports betting
# input: whitespace delimited list of US-style
# odds and bet sizes.
# if bet size is omitted from the input
# then a bet size to win 1 unit is assumed
use strict;
use warnings;
### edit from here ###
use constant EDGE => 0;
use constant TRIALS => 3_000_000;
use constant BOGEY => 0.1572035; # as % of risk amount
### don't edit below this line unless you know what you're doing ###
my @odds_ra = ();
my $total_risk = 0;
while(<>) {
chomp;
my ($us, $bet_size) = split;
next unless $us;
my $dec = &us2dec($us);
my $prob = (1+EDGE)/$dec;
my $risk = defined $bet_size ? $bet_size : 1/($dec-1);
my $win = $risk * ($dec - 1);
push @odds_ra, [$prob, $dec, $risk, $win];
$total_risk += $risk;
}
my ($sum,$sumsq,$qualifiers,) = (0.0, 0.0, 0,);
my $pct_bogey = BOGEY * $total_risk ;
foreach my $i ( 1 .. TRIALS) {
my $this_trial_result = 0;
print STDERR "Trial $i\n" if $i%10_000 == 0;
foreach my $j (0 .. $#odds_ra) {
my ($prob, $dec, $risk, $win,) = @{$odds_ra[$j]};
my $r = rand();
my $this_bet_result;
if ($r < $prob) {
# win
$this_bet_result = $win;
} else {
$this_bet_result = -$risk;
}
$this_trial_result += $this_bet_result;
}
print "$this_trial_result\n";
$qualifiers++ if $this_trial_result >= $pct_bogey;
$sum += $this_trial_result;
$sumsq += $this_trial_result*$this_trial_result;
}
my $mean = $sum / TRIALS;
my $stddev = sqrt($sumsq / TRIALS - $mean*$mean);
my $frequency = $qualifiers / TRIALS;
print STDERR "Mean \t$mean\n";
print STDERR "Std. Dev.\t$stddev\n";
print STDERR "Qual \t$frequency\n";
sub us2dec {
my $us = shift;
return (
$us >= 0 ? 1+$us/100 : 1-100/$us
);
}
The input should should contain a list of US-style odds and bet sizes separated by a tab or a space. Each new bet should (as before) be on a its own line. For backwards compatability if no bet size is given the script still assumes betting to win a single unit.
Modifying the code to accept edges rather than bet sizes and then calculate n-Kelly from there should be trivial.
First off and for whatever it's worth, while betting to win 1/4 edge is typically a very accurate approximation to quarter-Kelly it isn't really quarter-Kelly. The exact formula for single-bet quarter-Kelly would be:
K¼ = ( (wp)0.25 - (1 - p)0.25 ) / ((wp)0.25 + w * (1 - p)0.25) if > 0
And for n-Kelly:
Kn = ( (wp)n - (1 - p)n ) / ((wp)n + w * (1 - p)n) if > 0
I have to say that you're probably best off learning a bit of a Perl so you can tailor the above program to your own personal needs (or redoing the entire program in a language with which you already comfortable. As I'm sure you can understand I don't really want to get into the habit of programming-on-demand for every poster that asks.
Yeah, I would have to agree that you providing this code-on-demand service for SBR is really very convenient and I could see how it could get out of hand quickly. Thanks for everything you've done.
Regarding the correct n-Kelly amounts, I have played with your online Kelly calculator to figure out how to convert edge and odds to win percentage but have not been able to come up with the formula.
For example, If I have +200 and edge of .05 and -150 and edge of .02, how do I calculate win %'s so I can put it into the Kelly equation you have given?
Location: Forest Hills, NY, Home of the Blitzkrieg Bop
Posts: 4,631
Quote:
Originally Posted by VideoReview
Yeah, I would have to agree that you providing this code-on-demand service for SBR is really very convenient and I could see how it could get out of hand quickly. Thanks for everything you've done.
I hope you noticed that I modified the code in this post to do what you had wanted.
Quote:
Originally Posted by VideoReview
Regarding the correct n-Kelly amounts, I have played with your online Kelly calculator to figure out how to convert edge and odds to win percentage but have not been able to come up with the formula.
1/4 Kelly=0.6195%
1/2 Kelly=1.2427%
3/4 Kelly=1.8695%
Full Kelly=2.5000%
Yes, that is a pretty big mistake and deserves a big flashing green number 2 for sure.
I would like to double check with you the -150 with 2% edge as well just in case there is some nuance for minus odds that I may miss (I take -150 as 100/150 or .6666666). I am really hoping I do not get a big blinking number again.
1/4 Kelly=0.7530%
1/2 Kelly=1.5040%
3/4 Kelly=2.2530%
Full Kelly=3.0000%
The input should contain a list of US-style odds and bet sizes separated by a tab or a space. Each new bet should (as before) be on a its own line. For backwards compatibility if no bet size is given the script still assumes betting to win a single unit.
Modifying the code to accept edges rather than bet sizes and then calculate n-Kelly from there should be trivial.
Ganch, I would like to use the Perl code with weights to determine my p value based on how much I bet on various odds. I believe when you wrote the code it was with the intention that I would enter a percentage edge that I figured I had for each bet as the weight (i.e. -120 .05 would represent -120 odds with an expected +EV of 5 percent). Is there anything I could put in the second column that would weight the odds by how much I bet assuming that I perceived the edge to be the same for all bets (or did not know the number)? For example, if I had the following bets:
-120 120.00
150 80.00
1200 1.00
-110 70.00
The second column is how much I have bet. I was thinking of making the weight column the amount of money that would have been won if the bet did win.
Basically, getting rid of bets that were cancelled or a push, my final numbers for the last quarter were:
Win=47.42176
Bet=42.90906
# Of Bets (excluding push and cancel)=602
My bets, for the most part, were fairly close to even odds for the most part but the dollar values increased by about 5 times over the course of the quarter. I am trying to determine the probability that the results were random. Using the CLT, I get 1-NORMSDIST((47.42176-42.90906)/sqrt(42.90906)=0. The inside of part of the NORMSDIST equation evaluates to 21.78522 which I understand to mean that the results were 21.78522 standard deviations away from the mean, which is essentially zero. The only concern I have is that my bet sizes may not be normally distrubuted which is why I would like to do a Monte Carlo run.