Chula! Chula! Using all sorts Using all sorts of SAS to simulate of SAS to simulate and handicap jai- and handicap jai- alai games for fun alai games for fun (and profit ???) (and profit ???) Steve Grilli Steve Grilli Life Office Management Association Life Office Management Association
21
Embed
Chula! Using all sorts of SAS to simulate and handicap jai-alai games for fun (and profit ???) Steve Grilli Life Office Management Association.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
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
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
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
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;
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
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
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