chula! using all sorts of sas to simulate and handicap jai-alai games for fun (and profit ???) steve...
TRANSCRIPT
Chula! Chula! Using all sorts of Using all sorts of SAS to simulate and SAS to simulate and
handicap jai-alai games for handicap jai-alai games for fun (and profit ???)fun (and profit ???)
Steve GrilliSteve Grilli
Life Office Management AssociationLife Office Management Association
Presentation OutlinePresentation OutlineIntro: Steven Skiena’s Intro: Steven Skiena’s Calculated BetsCalculated Bets
Jai AlaiJai 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 SystemUsing 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 IssuesSAS 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 payouts
Conclusions Conclusions
DISCLAIMERDISCLAIMER
““Fun” SAS applicationFun” SAS application
Not advocating gambling ! ! !Not advocating gambling ! ! !
Internet gambling is considered Internet gambling is considered illegalillegal by US Dept. of Justice, and State of by US Dept. of Justice, and State of Georgia ! ! !Georgia ! ! !
THE BOOKTHE BOOK
Calculated Bets: Computers, Gambling, and Calculated Bets: Computers, Gambling, and Mathematical Modeling to WinMathematical Modeling to Win
by Steven Skiena by Steven Skiena
Professor of Computer ScienceProfessor of Computer Science
SUNY Stony BrookSUNY Stony Brook
(Cambrigde University Press and Mathematical Association of America, 2001)
THE GAME OF JAI ALAITHE GAME OF JAI ALAI Originated in the Basque Originated in the Basque
RegionRegion Players use a “basket” Players use a “basket”
((cestacesta) to fire a hard ball ) to fire a hard ball ((pelotapelota) against a wall.) against a wall.
Must be caught and Must be caught and returned on the fly or one returned on the fly or one bouncebounce
In U.S. eight players or In U.S. eight players or doubles teams rotatedoubles teams rotate
Pari-mutuel gambling Pari-mutuel gambling allowed at allowed at frontonfronton and off- and off-site betting establishmentssite betting establishments
BETTING TERMINOLOGYBETTING TERMINOLOGY
Money goes into POOLSMoney goes into POOLS
• Win, Place, ShowWin, Place, Show• QuinellaQuinella• ExactaExacta (Perfecta) (Perfecta)• TrifectaTrifecta
PARI-MUTUEL WAGERINGPARI-MUTUEL WAGERING Different from casino Different from casino
games where you play games where you play against the houseagainst the house
No fixed oddsNo fixed odds FrontonFronton (Jai Alai Stadium (Jai Alai Stadium
and its operators) take a and its operators) take a cut of each pool off the topcut of each pool off the top
Quite high (over 20%)Quite high (over 20%) Good news: they don’t Good news: they don’t
care who winscare who wins More that’s wagered, the More that’s wagered, the
more the fronton makesmore the fronton makes
How Games Are ScoredHow Games Are Scored Eight players (or double teams)Eight players (or double teams) Color-coded Posts 1-8Color-coded Posts 1-8 Player 1 serves to Player 2Player 1 serves to Player 2 Winner of point stays on the courtWinner of point stays on the court Loser goes to the end of the lineLoser goes to the end of the line Next player in the queue takes the courtNext player in the queue takes the court First time through rotation points worth oneFirst time through rotation points worth one After all 8 players have taken the court points After all 8 players have taken the court points
worth twoworth two Games played to 7 or 9 pointsGames played to 7 or 9 points
Simulating Games 1: What Do We Need?Simulating Games 1: What Do We Need?
A basic player skill measure: Point-A basic player skill measure: Point-win Percentage (PTWPER)win Percentage (PTWPER)
A probability function that generates A probability function that generates the probability that Player A with the probability that Player A with PTWPER-A wins the point against PTWPER-A wins the point against Player B with PTWPER-BPlayer B with PTWPER-B
1 Pr( ) Pr( )Pr( , ) if Pr( ) Pr( )
2
1 Pr( ) Pr( )Pr( , ) if Pr( ) Pr( )
2
A BA B A B
B AA B A B
Simulating Games 2: The Probability Simulating Games 2: The Probability FunctionFunction
Alpha is the keyAlpha is the key
Ex: Player A PTWPER = 0.525Ex: Player A PTWPER = 0.525 Player B PTWPER = 0.475Player B PTWPER = 0.475
Alpha= 1.0; A wins 52.5%Alpha= 1.0; A wins 52.5%Alpha= 0.4; A wins 65.1%Alpha= 0.4; A wins 65.1%
1 Pr( ) Pr( )Pr( , ) if Pr( ) Pr( )
2
1 Pr( ) Pr( )Pr( , ) if Pr( ) Pr( )
2
A BA B A B
B AA B A B
Simulating Games 3: SAS CodeSimulating Games 3: SAS Code
/* simulate winner */;/* simulate winner */;
do until(win gt do until(win gt 00););
pt+pt+11;;
alpha=&alph;alpha=&alph;
if wper(Op1) ge wper(Op2) thenif wper(Op1) ge wper(Op2) then
winop12= winop12= .5.5*(*(11 + (wper(Op1)- + (wper(Op1)-wper(Op2))**alpha);wper(Op2))**alpha);
else winop12= else winop12= .5.5*(*(11 - (wper(Op2)- - (wper(Op2)-wper(Op1))**alpha);wper(Op1))**alpha);
if ranuni(if ranuni(00) lt winop12 then do;) lt winop12 then do; Ppt(Op1)+Ppt(Op1)+11;; Ppt(Op2)+Ppt(Op2)+11;; Pptw(Op1)+Pptw(Op1)+11;; q(pt+q(pt+66)=Op2;)=Op2; Op2=q(pt);Op2=q(pt); if pt le if pt le 77 then Sc(Op1)+ then Sc(Op1)+11;;
else Sc(Op1)+else Sc(Op1)+22;; if Sc(Op1) ge game then do;if Sc(Op1) ge game then do; win=Op1;win=Op1; Sc(Op1)=-Sc(Op1)=-11;; end;end; end;end;
else do;else do; Ppt(Op1)+Ppt(Op1)+11;; Ppt(Op2)+Ppt(Op2)+11;; Pptw(Op2)+Pptw(Op2)+11;; q(pt+q(pt+66)=Op1;)=Op1; if pt le if pt le 77 then Sc(Op2)+ then Sc(Op2)+11;; else Sc(Op2)+else Sc(Op2)+22;;
if Sc(Op2) ge game then do;if Sc(Op2) ge game then do; win=Op2;win=Op2; Sc(Op2)=-Sc(Op2)=-11;; end;end;
Op1=Op2;Op1=Op2; Op2=q(pt);Op2=q(pt); end;end; end;end;
Simulating Games 4: Some SAS OutputSimulating Games 4: Some SAS Output
GAME 6 GAME 6
PTWPER GACT TEAM POSTPTWPER GACT TEAM POST
0.49598 93 JAIRO-LARREA 10.49598 93 JAIRO-LARREA 1 0.54231 77 LECUE-CHASIO 20.54231 77 LECUE-CHASIO 2 0.45431 104 TOTO-MADARIETA 30.45431 104 TOTO-MADARIETA 3 0.50832 82 SCOTTY-ERKIAGA II 40.50832 82 SCOTTY-ERKIAGA II 4 0.51901 64 OCHOA-PEDRO 50.51901 64 OCHOA-PEDRO 5 0.47931 68 OLATE-CARVALHO 60.47931 68 OLATE-CARVALHO 6 0.46634 30 BARRE-AZPIRI 70.46634 30 BARRE-AZPIRI 7 0.48200 122 ARECHA-URTARAN 80.48200 122 ARECHA-URTARAN 8
Simulating Games 4: More SAS OutputSimulating Games 4: More SAS Output
The FREQ ProcedureThe FREQ Procedure
Cumulative CumulativeCumulative Cumulative EX Frequency Percent Frequency PercentEX Frequency Percent Frequency Percent
1-2 9495 3.80 9495 3.801-2 9495 3.80 9495 3.80 1-3 4606 1.84 14101 5.641-3 4606 1.84 14101 5.64 1-4 5443 2.18 19544 7.821-4 5443 2.18 19544 7.82 1-5 6382 2.55 25926 10.371-5 6382 2.55 25926 10.37 1-6 4219 1.69 30145 12.061-6 4219 1.69 30145 12.06 1-7 4040 1.62 34185 13.671-7 4040 1.62 34185 13.67 1-8 3747 1.50 37932 15.171-8 3747 1.50 37932 15.17 2-1 12541 5.02 50473 20.192-1 12541 5.02 50473 20.19 2-3 7509 3.00 57982 23.192-3 7509 3.00 57982 23.19 2-4 8429 3.37 66411 26.562-4 8429 3.37 66411 26.56 2-5 9609 3.84 76020 30.412-5 9609 3.84 76020 30.41 2-6 6408 2.56 82428 32.972-6 6408 2.56 82428 32.97 2-7 6250 2.50 88678 35.472-7 6250 2.50 88678 35.47 2-8 6536 2.61 95214 38.092-8 6536 2.61 95214 38.09
GAME 6 EXACTA SELECTIONS GAME 6 EXACTA SELECTIONS
GDATE GTIME GM GT GPTS TYP SEL PR RETGDATE GTIME GM GT GPTS TYP SEL PR RET 16828 EVE 6 D 7 E 2-1 0.05016 1.1664716828 EVE 6 D 7 E 2-1 0.05016 1.16647 16828 EVE 6 D 7 E 2-5 0.03844 1.0624516828 EVE 6 D 7 E 2-5 0.03844 1.06245
Simulating Games 5: Bet SelectionSimulating Games 5: Bet Selection
MeanPayoutExacta Exacta( ) Pr( ) ( )x x xE
Parsing Internet Files: Results FilesParsing Internet Files: Results Files
GAME 6GAME 6
2 Lecue-Chasio 9.40 4.40 4.202 Lecue-Chasio 9.40 4.40 4.20 1 Jairo-Larrea 5.40 3.601 Jairo-Larrea 5.40 3.60 5 Ochoa-Pedro 3.805 Ochoa-Pedro 3.80
QUINIELA 1-2 24.60QUINIELA 1-2 24.60 EXACTA 2-1 101.70EXACTA 2-1 101.70 TRIFECTA 2-1-5 221.60TRIFECTA 2-1-5 221.60
SAS FUNCTIONSSAS FUNCTIONS
• INDEX ()INDEX ()• SCAN ()SCAN ()• Also, conditional Also, conditional
input statementsinput statements
Bet Selection AnalysisBet Selection Analysis
GAME 6 ANALYSIS OF RET CUTOFFSGAME 6 ANALYSIS OF RET CUTOFFS
RET N MEANPROF PERCOR TPROF COR LOWER UPPERRET N MEANPROF PERCOR TPROF COR LOWER UPPER
1.19 137 0.84672 0.058394 116.0 8 0.027991 0.107151.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.049711.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.143911.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.049321.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.048471.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.047131.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.088401.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.045741.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.075261.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.090461.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.038480.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.040630.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.040270.94 3538 0.35579 0.033917 1258.8 120 0.028329 0.04027
System Structure SummarySystem Structure Summary
Parse entries .txt file from fronton Parse entries .txt file from fronton websitewebsite
Simulate games; select betsSimulate games; select bets Parse entry changes .txt file; Parse entry changes .txt file;
resimulate any games with changesresimulate any games with changes Finalize betsFinalize bets Parse results .txt fileParse results .txt file Update SAS data sets (PTWPER, Update SAS data sets (PTWPER,
Mean Payouts, et. al.)Mean Payouts, et. al.)
Research 1: Confidence Interval on Small Research 1: Confidence Interval on Small ProportionsProportions
2
(1 )p pp
nz
95% Jeffreys interval:95% Jeffreys interval:
LOWER=BETAINV(LOWER=BETAINV(.025.025,COR+,COR+0.500.50 ,N-COR+ ,N-COR+0.500.50);); UPPER= BETAINV(UPPER= BETAINV(.975.975,COR+,COR+0.500.50, N-COR+, N-COR+0.500.50););
Research 2: “Hot Hand” and Player Skill Research 2: “Hot Hand” and Player Skill EstimationEstimation
Statisticians still argue about the Statisticians still argue about the existence of streaks in sportsexistence of streaks in sports
If we had actual point-win data, we If we had actual point-win data, we can conduct researchcan conduct research
Use GEE option in PROC GENMODUse GEE option in PROC GENMOD Use PROC FACTOR to build a weighed Use PROC FACTOR to build a weighed
index of long and short term PTWPERindex of long and short term PTWPER
Research 3: Improving the Estimate of Mean Research 3: Improving the Estimate of Mean PayoutPayout
1 2
1
2
PTWPER-ALL PTWPER-W PTWPER-ALL PTWPER-P
PTWPER-ALL PTWPER-W
PTWPER-ALL PTWPER-P
ln( ) ln( ) ln
ln
( ) ( )
( )
( )
NewPay MeanPay
NewPay MeanPay
CONCLUSIONSCONCLUSIONS
SAS works for the three major areas of SAS works for the three major areas of this type of gaming application: this type of gaming application: parsing internet files, simulation of parsing internet files, simulation of the games, and analysis & researchthe games, and analysis & research
Profit? System is still under Profit? System is still under construction, but profitable in terms construction, but profitable in terms of personal development as of personal development as statistician and SAS programmerstatistician and SAS programmer