Steve Grilli Life Office Management Association Chula! Using all sorts of SAS to simulate and handicap jai-alai games for fun (and profit ???) Steve Grilli Life Office Management Association Copyright 2006 by Steve Grilli/RSB Associates (may not be displayed without this notice)
Presentation Outline Intro: Steven Skiena’s Calculated Bets Jai Alai -- The Game -- Betting Terminology -- Pari-mutuel Wagering -- How Games are Scored Using SAS to Engineer the System -- Simulating Games -- Parsing Internet Files -- Bet Selection Analysis SAS and Selected Research Issues -- Confidence Limits on small proportions -- “Hot hands” and players’ skill levels -- Modelling mean payouts Conclusions
DISCLAIMER “Fun” SAS application Not advocating gambling ! ! ! Internet gambling is considered illegal by US Dept. of Justice, and State of Georgia ! ! !
THE BOOK Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win by Steven Skiena Professor of Computer Science SUNY Stony Brook (Cambrigde University Press and Mathematical Association of America, 2001) Wonderful, personal, non-technical description of how to apply math, stats, and computer programming to gaming and sports problems. At heart of book is description of his jai alai betting system, Maven (Yiddesh for “self-proclaimed expert”). He uses PERL to parse interent files and C++ to simulate the jai alai games, combined with the fact that off-track gambling is legal in NY, he and his crew turned $250 into over $1,500 (he gave the money to charity) Why not try his approach in SAS?
THE GAME OF JAI ALAI Originated in the Basque Region Players use a “basket” (cesta) to fire a hard ball (pelota) against a wall. Must be caught and returned on the fly or one bounce In U.S. eight players or doubles teams rotate Pari-mutuel gambling allowed at fronton and off-site betting establishments (Goikoetxea on right may be the best player in the world) Pelota has been clocked at over 180 mph. Pictures courtesy of Tiger’s Jai Alai Heaven.
BETTING TERMINOLOGY Money goes into POOLS Win, Place, Show Quinella Exacta (Perfecta) Trifecta Also, more exotic bets: boxes, wheels
PARI-MUTUEL WAGERING Different from casino games where you play against the house No fixed odds Fronton (Jai Alai Stadium and its operators) take a cut of each pool off the top Quite high (over 20%) Good news: they don’t care who wins More that’s wagered, the more the fronton makes Plenty of games – Dania Jai Alai has 8 performances/wk – matinees and evenings -- of 13 or 14 games (109 games/wk)
How Games Are Scored Eight players (or double teams) Color-coded Posts 1-8 Player 1 serves to Player 2 Winner of point stays on the court Loser goes to the end of the line Next player in the queue takes the court First time through rotation points worth one After all 8 players have taken the court points worth two Games played to 7 or 9 points Tiebrakers for place and show. Posts position very important to success
Simulating Games 1: What Do We Need? A basic player skill measure: Point-win Percentage (PTWPER) A probability function that generates the probability that Player A with PTWPER-A wins the point against Player B with PTWPER-B PTWPER not kept by frontons; must be imputed by w,p,s, out-of-money results by POST position Steve Skiena: prob function should have integrity, symmetry, monotonicity, generality, equality, simplicity
Simulating Games 2: The Probability Function Alpha is the key Ex: Player A PTWPER = 0.525 Player B PTWPER = 0.475 Alpha= 1.0; A wins 52.5% Alpha= 0.4; A wins 65.1% Difference between Poisson variates – 1948 J Royal Statistical Society
Simulating Games 3: SAS Code else Sc(Op1)+2; if Sc(Op1) ge game then do; win=Op1; Sc(Op1)=-1; end; else do; Ppt(Op1)+1; Ppt(Op2)+1; Pptw(Op2)+1; q(pt+6)=Op1; if pt le 7 then Sc(Op2)+1; else Sc(Op2)+2; if Sc(Op2) ge game then do; win=Op2; Sc(Op2)=-1; Op1=Op2; Op2=q(pt); /* simulate winner */; do until(win gt 0); pt+1; alpha=&alph; if wper(Op1) ge wper(Op2) then winop12= .5*(1 + (wper(Op1)-wper(Op2))**alpha); else winop12= .5*(1 - (wper(Op2)-wper(Op1))**alpha); if ranuni(0) lt winop12 then do; Ppt(Op1)+1; Ppt(Op2)+1; Pptw(Op1)+1; q(pt+6)=Op2; Op2=q(pt); if pt le 7 then Sc(Op1)+1; queue q initialized 3-8. Monte Carlo simulation – random number generation on uniform(0,1) distribution
Simulating Games 4: Some SAS Output PTWPER GACT TEAM POST 0.49598 93 JAIRO-LARREA 1 0.54231 77 LECUE-CHASIO 2 0.45431 104 TOTO-MADARIETA 3 0.50832 82 SCOTTY-ERKIAGA II 4 0.51901 64 OCHOA-PEDRO 5 0.47931 68 OLATE-CARVALHO 6 0.46634 30 BARRE-AZPIRI 7 0.48200 122 ARECHA-URTARAN 8
Simulating Games 4: More SAS Output The FREQ Procedure Cumulative Cumulative EX Frequency Percent Frequency Percent 1-2 9495 3.80 9495 3.80 1-3 4606 1.84 14101 5.64 1-4 5443 2.18 19544 7.82 1-5 6382 2.55 25926 10.37 1-6 4219 1.69 30145 12.06 1-7 4040 1.62 34185 13.67 1-8 3747 1.50 37932 15.17 2-1 12541 5.02 50473 20.19 2-3 7509 3.00 57982 23.19 2-4 8429 3.37 66411 26.56 2-5 9609 3.84 76020 30.41 2-6 6408 2.56 82428 32.97 2-7 6250 2.50 88678 35.47 2-8 6536 2.61 95214 38.09
Simulating Games 4: Bet Selection GAME 6 EXACTA SELECTIONS GDATE GTIME GM GT GPTS TYP SEL PR RET 16828 EVE 6 D 7 E 2-1 0.05016 1.16647 16828 EVE 6 D 7 E 2-5 0.03844 1.06245 Expected Value of a dollar bet on Exacta x
Parsing Internet Files: Results Files GAME 6 2 Lecue-Chasio 9.40 4.40 4.20 1 Jairo-Larrea 5.40 3.60 5 Ochoa-Pedro 3.80 QUINIELA 1-2 24.60 EXACTA 2-1 101.70 TRIFECTA 2-1-5 221.60 SAS FUNCTIONS INDEX () SCAN () Also, conditional input statements Dania – Parse Entries, Changes, Results. From Results we want win, place, show team, posts, date, game number, pool payouts. Use the standard character functions to parse.
Bet Selection Analysis GAME 6 ANALYSIS OF RET CUTOFFS RET N MEANPROF PERCOR TPROF COR LOWER UPPER 1.19 137 0.84672 0.058394 116.0 8 0.027991 0.10715 1.03 1443 0.66334 0.038808 957.2 56 0.029749 0.04971 1.23 63 0.61905 0.063492 39.0 4 0.021809 0.14391 1.04 1294 0.61731 0.037867 798.8 49 0.028478 0.04932 1.05 1152 0.55104 0.036458 634.8 42 0.026771 0.04847 1.02 1618 0.54042 0.037083 874.4 60 0.028687 0.04713 1.17 211 0.50616 0.052133 106.8 11 0.028010 0.08840 1.01 1790 0.44134 0.036313 790.0 65 0.028382 0.04574 1.15 299 0.41271 0.046823 123.4 14 0.027085 0.07526 1.18 163 0.39264 0.049080 64.0 8 0.023473 0.09046 0.89 5330 0.36968 0.033396 1970.4 178 0.028823 0.03848 0.93 3854 0.35864 0.034510 1382.2 133 0.029092 0.04063 0.94 3538 0.35579 0.033917 1258.8 120 0.028329 0.04027 Sort by descending MEANPROF (per $2 bet)
System Structure Summary Parse entries .txt file from fronton website Simulate games; select bets Parse entry changes .txt file; resimulate any games with changes Finalize bets Parse results .txt file Update SAS data sets (PTWPER, Mean Payouts, et. al.) Change file: Grilli’s No. 1 rule of sports handicapping: never bet on a horse who isn’t running in the race.
Research 1: Confidence Interval on Small Proportions 95% Jeffreys interval: LOWER=BETAINV(.025,COR+0.50 ,N-COR+0.50); UPPER= BETAINV(.975,COR+0.50, N-COR+0.50); Beta distribution is conjugate prior for parameter p for binomial data. Source: Brown, Cai, and DasGupta “Interval estimation for a binomial proportion” Statistical Science, 2001
Research 2: “Hot Hand” and Player Skill Estimation Statisticians still argue about the existence of streaks in sports If we had actual point-win data, we can conduct research Use GEE option in PROC GENMOD Use PROC FACTOR to build a weighed index of long and short term PTWPER Model win proportion on a game basis (correlated obs) as a function of long, short term PTWPER.
Research 3: Improving the Estimate of Mean Payout Model coefficients B1, B2 significant at p < .0001. Improves estimate of actual payout in 58% of 5,936 cases
CONCLUSIONS SAS works for the three major areas of this type of gaming application: parsing internet files, simulation of the games, and analysis & research Profit? System is still under construction, but profitable in terms of personal development as statistician and SAS programmer Final quote from “Fast Eddie” Felsen: “Money won is twice as sweet as money earned.” Take questions