Chula Using all sorts of SAS to simulate

  • Slides: 21
Download presentation
Chula! Using all sorts of SAS to simulate and handicap jai-alai games for fun

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

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

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

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)

THE GAME OF JAI ALAI n n n Originated in the Basque Region Players

THE GAME OF JAI ALAI n n n 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 offsite betting establishments

BETTING TERMINOLOGY Money goes into POOLS • • Win, Place, Show Quinella Exacta (Perfecta)

BETTING TERMINOLOGY Money goes into POOLS • • Win, Place, Show Quinella Exacta (Perfecta) Trifecta

PARI-MUTUEL WAGERING n n n Different from casino games where you play against the

PARI-MUTUEL WAGERING n n n 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

How Games Are Scored n n n n n Eight players (or double teams)

How Games Are Scored n n n n n 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

Simulating Games 1: What Do We Need? § § A basic player skill measure:

Simulating Games 1: What Do We Need? § § A basic player skill measure: Pointwin 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 Ex: Player A PTWPER

Simulating Games 2: The Probability Function Alpha is the key Ex: Player A PTWPER = 0. 525 Player B PTWPER = 0. 475 Alpha= 1. 0; 0. 4; A A wins 52. 5% 65. 1%

Simulating Games 3: SAS Code n n n n /* simulate winner */; do

Simulating Games 3: SAS Code n n n n /* simulate winner */; do until(win gt 0); pt+1; alpha=&alph; if wper(Op 1) ge wper(Op 2) then winop 12=. 5*(1 + (wper(Op 1)wper(Op 2))**alpha); else winop 12=. 5*(1 - (wper(Op 2)wper(Op 1))**alpha); if ranuni(0) lt winop 12 then do; n Ppt(Op 1)+1; n Ppt(Op 2)+1; n Pptw(Op 1)+1; n q(pt+6)=Op 2; n Op 2=q(pt); n if pt le 7 then Sc(Op 1)+1; n n n else Sc(Op 1)+2; if Sc(Op 1) ge game then do; win=Op 1; Sc(Op 1)=-1; end; else do; Ppt(Op 1)+1; Ppt(Op 2)+1; Pptw(Op 2)+1; q(pt+6)=Op 1; n n n n n if pt le 7 then Sc(Op 2)+1; else Sc(Op 2)+2; if Sc(Op 2) ge game then do; win=Op 2; Sc(Op 2)=-1; end; Op 1=Op 2; Op 2=q(pt); end; n n end;

Simulating Games 4: Some SAS Output GAME 6 n n n n PTWPER 0.

Simulating Games 4: Some SAS Output GAME 6 n n n n PTWPER 0. 49598 0. 54231 0. 45431 0. 50832 0. 51901 0. 47931 0. 46634 0. 48200 GACT 93 77 104 82 64 68 30 122 TEAM JAIRO-LARREA LECUE-CHASIO TOTO-MADARIETA SCOTTY-ERKIAGA II OCHOA-PEDRO OLATE-CARVALHO BARRE-AZPIRI ARECHA-URTARAN POST 1 2 3 4 5 6 7 8

Simulating Games 4: More SAS Output The FREQ Procedure n n n n n

Simulating Games 4: More SAS Output The FREQ Procedure n n n n n EX Frequency 1 -2 1 -3 1 -4 1 -5 1 -6 1 -7 1 -8 2 -1 2 -3 2 -4 2 -5 2 -6 2 -7 2 -8 9495 4606 5443 6382 4219 4040 3747 12541 7509 8429 9609 6408 6250 6536 Cumulative Percent Frequency Percent 3. 80 1. 84 2. 18 2. 55 1. 69 1. 62 1. 50 5. 02 3. 00 3. 37 3. 84 2. 56 2. 50 2. 61 9495 14101 19544 25926 30145 34185 37932 50473 57982 66411 76020 82428 88678 95214 3. 80 5. 64 7. 82 10. 37 12. 06 13. 67 15. 17 20. 19 23. 19 26. 56 30. 41 32. 97 35. 47 38. 09

Simulating Games 4: Bet Selection GAME 6 EXACTA SELECTIONS n GDATE GTIME GM GT

Simulating Games 4: Bet Selection GAME 6 EXACTA SELECTIONS n GDATE GTIME GM GT GPTS TYP SEL PR RET n n n 16828 EVE 6 6 D D 7 7 E E 2 -1 0. 05016 1. 16647 2 -5 0. 03844 1. 06245

Parsing Internet Files: Results Files GAME 6 n n n 2 1 5 Lecue-Chasio

Parsing Internet Files: Results Files GAME 6 n n n 2 1 5 Lecue-Chasio 9. 40 4. 20 Jairo-Larrea 5. 40 3. 60 Ochoa-Pedro 3. 80 QUINIELA EXACTA TRIFECTA 1 -2 2 -1 -5 24. 60 101. 70 221. 60 SAS FUNCTIONS • • • INDEX () SCAN () Also, conditional input statements

Bet Selection Analysis GAME 6 ANALYSIS OF RET CUTOFFS n n n n RET

Bet Selection Analysis GAME 6 ANALYSIS OF RET CUTOFFS n n n n RET 1. 19 1. 03 1. 23 1. 04 1. 05 1. 02 1. 17 1. 01 1. 15 1. 18 0. 89 0. 93 0. 94 N 137 1443 63 1294 1152 1618 211 1790 299 163 5330 3854 3538 MEANPROF PERCOR 0. 84672 0. 66334 0. 61905 0. 61731 0. 55104 0. 54042 0. 50616 0. 44134 0. 41271 0. 39264 0. 36968 0. 35864 0. 35579 0. 058394 0. 038808 0. 063492 0. 037867 0. 036458 0. 037083 0. 052133 0. 036313 0. 046823 0. 049080 0. 033396 0. 034510 0. 033917 TPROF COR LOWER UPPER 116. 0 957. 2 39. 0 798. 8 634. 8 874. 4 106. 8 790. 0 123. 4 64. 0 1970. 4 1382. 2 1258. 8 8 56 4 49 42 60 11 65 14 8 178 133 120 0. 027991 0. 029749 0. 021809 0. 028478 0. 026771 0. 028687 0. 028010 0. 028382 0. 027085 0. 023473 0. 028823 0. 029092 0. 028329 0. 10715 0. 04971 0. 14391 0. 04932 0. 04847 0. 04713 0. 08840 0. 04574 0. 07526 0. 09046 0. 03848 0. 04063 0. 04027

System Structure Summary n n n Parse entries. txt file from fronton website Simulate

System Structure Summary n n n 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. )

Research 1: Confidence Interval on Small Proportions 95% Jeffreys interval: n n LOWER=BETAINV(. 025,

Research 1: Confidence Interval on Small Proportions 95% Jeffreys interval: n n LOWER=BETAINV(. 025, 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 n n Statisticians still argue about

Research 2: “Hot Hand” and Player Skill Estimation n n 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

Research 3: Improving the Estimate of Mean Payout

Research 3: Improving the Estimate of Mean Payout

CONCLUSIONS SAS works for the three major areas of this type of gaming application:

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