Chula! Using all sorts of SAS to simulate and handicap jai-alai games for fun (and profit ???) Steve Grilli Life Office Management Association
Presentation Outline Intro: Steven Skiena’s Calculated Bets Jai Alai -- The Game -- The Game -- Betting Terminology -- Betting Terminology -- Pari-mutuel Wagering -- Pari-mutuel Wagering -- How Games are Scored -- How Games are Scored Using SAS to Engineer the System -- Simulating Games -- Simulating Games -- Parsing Internet Files -- Parsing Internet Files -- Bet Selection Analysis -- Bet Selection Analysis SAS and Selected Research Issues -- Confidence Limits on small proportions -- Confidence Limits on small proportions -- “Hot hands” and players’ skill levels -- “Hot hands” and players’ skill levels -- Modelling mean payouts -- Modelling mean payoutsConclusions
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 by Steven Skiena Professor of Computer Science Professor of Computer Science SUNY Stony Brook SUNY Stony Brook (Cambrigde University Press and Mathematical Association of America, 2001)
THE GAME OF JAI ALAI Originated in the Basque Region Originated in the Basque Region Players use a “basket” (cesta) to fire a hard ball (pelota) against a wall. 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 Must be caught and returned on the fly or one bounce In U.S. eight players or doubles teams rotate In U.S. eight players or doubles teams rotate Pari-mutuel gambling allowed at fronton and off- site betting establishments Pari-mutuel gambling allowed at fronton and off- site betting establishments
BETTING TERMINOLOGY Money goes into POOLS Win, Place, Show Win, Place, Show Quinella Quinella Exacta (Perfecta) Exacta (Perfecta) Trifecta Trifecta
PARI-MUTUEL WAGERING Different from casino games where you play against the house Different from casino games where you play against the house No fixed odds No fixed odds Fronton (Jai Alai Stadium and its operators) take a cut of each pool off the top Fronton (Jai Alai Stadium and its operators) take a cut of each pool off the top Quite high (over 20%) Quite high (over 20%) Good news: they don’t care who wins Good news: they don’t care who wins More that’s wagered, the more the fronton makes More that’s wagered, the more the fronton makes
How Games Are Scored Eight players (or double teams) Eight players (or double teams) Color-coded Posts 1-8 Color-coded Posts 1-8 Player 1 serves to Player 2 Player 1 serves to Player 2 Winner of point stays on the court Winner of point stays on the court Loser goes to the end of the line Loser goes to the end of the line Next player in the queue takes the court Next player in the queue takes the court First time through rotation points worth one First time through rotation points worth one After all 8 players have taken the court points worth two After all 8 players have taken the court points worth two Games played to 7 or 9 points Games played to 7 or 9 points
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
Simulating Games 2: The Probability Function Alpha is the key Alpha is the key Ex: Player A PTWPER = Player B PTWPER = Player B PTWPER = Alpha= 1.0; A wins 52.5% Alpha= 0.4; A wins 65.1%
Simulating Games 3: SAS Code /* simulate winner */; /* simulate winner */; do until(win gt 0); do until(win gt 0); pt+1; pt+1; alpha=&alph; alpha=&alph; if wper(Op1) ge wper(Op2) then if wper(Op1) ge wper(Op2) then winop12=.5*(1 + (wper(Op1)- wper(Op2))**alpha); winop12=.5*(1 + (wper(Op1)- wper(Op2))**alpha); else winop12=.5*(1 - (wper(Op2)- wper(Op1))**alpha); else winop12=.5*(1 - (wper(Op2)- wper(Op1))**alpha); if ranuni(0) lt winop12 then do; if ranuni(0) lt winop12 then do; Ppt(Op1)+1; Ppt(Op1)+1; Ppt(Op2)+1; Ppt(Op2)+1; Pptw(Op1)+1; Pptw(Op1)+1; q(pt+6)=Op2; q(pt+6)=Op2; Op2=q(pt); Op2=q(pt); if pt le 7 then Sc(Op1)+1; if pt le 7 then Sc(Op1)+1; else Sc(Op1)+2; else Sc(Op1)+2; if Sc(Op1) ge game then do; if Sc(Op1) ge game then do; win=Op1; win=Op1; Sc(Op1)=-1; Sc(Op1)=-1; end; end; else do; else do; Ppt(Op1)+1; Ppt(Op1)+1; Ppt(Op2)+1; Ppt(Op2)+1; Pptw(Op2)+1; Pptw(Op2)+1; q(pt+6)=Op1; q(pt+6)=Op1; if pt le 7 then Sc(Op2)+1; if pt le 7 then Sc(Op2)+1; else Sc(Op2)+2; else Sc(Op2)+2; if Sc(Op2) ge game then do; if Sc(Op2) ge game then do; win=Op2; win=Op2; Sc(Op2)=-1; Sc(Op2)=-1; end; end; Op1=Op2; Op1=Op2; Op2=q(pt); Op2=q(pt); end; end; end; end;
Simulating Games 4: Some SAS Output GAME 6 GAME 6 PTWPER GACT TEAM POST PTWPER GACT TEAM POST JAIRO-LARREA JAIRO-LARREA LECUE-CHASIO LECUE-CHASIO TOTO-MADARIETA TOTO-MADARIETA SCOTTY-ERKIAGA II SCOTTY-ERKIAGA II OCHOA-PEDRO OCHOA-PEDRO OLATE-CARVALHO OLATE-CARVALHO BARRE-AZPIRI BARRE-AZPIRI ARECHA-URTARAN ARECHA-URTARAN 8
Simulating Games 4: More SAS Output The FREQ Procedure The FREQ Procedure Cumulative Cumulative Cumulative Cumulative EX Frequency Percent Frequency Percent EX Frequency Percent Frequency Percent
GAME 6 EXACTA SELECTIONS GAME 6 EXACTA SELECTIONS GDATE GTIME GM GT GPTS TYP SEL PR RET GDATE GTIME GM GT GPTS TYP SEL PR RET EVE 6 D 7 E EVE 6 D 7 E EVE 6 D 7 E EVE 6 D 7 E Simulating Games 5: Bet Selection
Parsing Internet Files: Results Files GAME 6 GAME 6 2 Lecue-Chasio Lecue-Chasio Jairo-Larrea Jairo-Larrea Ochoa-Pedro Ochoa-Pedro 3.80 QUINIELA QUINIELA EXACTA EXACTA TRIFECTA TRIFECTA SAS FUNCTIONS INDEX () INDEX () SCAN () SCAN () Also, conditional input statements Also, conditional input statements
Bet Selection Analysis GAME 6 ANALYSIS OF RET CUTOFFS GAME 6 ANALYSIS OF RET CUTOFFS RET N MEANPROF PERCOR TPROF COR LOWER UPPER RET N MEANPROF PERCOR TPROF COR LOWER UPPER
System Structure Summary Parse entries.txt file from fronton website Parse entries.txt file from fronton website Simulate games; select bets Simulate games; select bets Parse entry changes.txt file; resimulate any games with changes Parse entry changes.txt file; resimulate any games with changes Finalize bets Finalize bets Parse results.txt file Parse results.txt file Update SAS data sets (PTWPER, Mean Payouts, et. al.) Update SAS data sets (PTWPER, Mean Payouts, et. al.)
Research 1: Confidence Interval on Small Proportions 95% Jeffreys interval: LOWER=BETAINV(.025,COR+0.50,N-COR+0.50); LOWER=BETAINV(.025,COR+0.50,N-COR+0.50); UPPER= BETAINV(.975,COR+0.50, N-COR+0.50); UPPER= BETAINV(.975,COR+0.50, N-COR+0.50);
Research 2: “Hot Hand” and Player Skill Estimation Statisticians still argue about the existence of streaks in sports Statisticians still argue about the existence of streaks in sports If we had actual point-win data, we can conduct research If we had actual point-win data, we can conduct research Use GEE option in PROC GENMOD Use GEE option in PROC GENMOD Use PROC FACTOR to build a weighed index of long and short term PTWPER Use PROC FACTOR to build a weighed index of long and short term PTWPER
Research 3: Improving the Estimate of Mean Payout
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