170 likes | 191 Views
Stat 35b: Introduction to Probability with Applications to Poker Outline for the day, Tues 2/26/13: Midterms back. Review of midterm. Poisson distribution, ch 5.5. (Hand of the day, Joe Hachem , Bob Bounhara , and David Sands.) 4. Continuous random variables, ch. 6.1.
E N D
Stat 35b: Introduction to Probability with Applications to Poker Outline for the day, Tues 2/26/13: • Midterms back. • Review of midterm. • Poisson distribution, ch 5.5. • (Hand of the day, Joe Hachem, Bob Bounhara, and David Sands.) • 4. Continuous random variables, ch. 6.1. • 5. Uniform, normal, and exponential distributions, ch 6.2-6.4. • 6. Project B functions. • 7. Project B example, Zelda. • Homework 3, due Thur Feb 28, 11am: 4.7, 4.8, 4.12, 4.16, 5.6, 6.2. • Project B is due Fri, March 8, 8pm, by email.
Midterms. Your score becomes Score/2 + 50, if you got < 100%. For instance, if you got 60/100, score this as 60/2 + 50 = 80. After this transformation, 90-100 = A range, 80-90 = B range, 70-80 = C range, etc. 2. Review of the midterm. Note that many of the final exam questions will be the same as, or similar to, midterm questions. On the final, you will get to use the book plus two 8.5 x 11 pages of notes, each double sided.
3. Poisson distribution, ch 5.5. Player 1 plays in a very slow game, 4 hands an hour, and she decides to do a big bluff whenever the second hand on her watch, at the start of the deal, is in some predetermined 10 second interval. Now suppose Player 2 plays in a game where about 10 hands are dealt per hour, so he similarly looks at his watch at the beginning of each poker hand, but only does a big bluff if the second hand is in a 4 second interval. Player 3 plays in a faster game where about 20 hands are dealt per hour, and she bluffs only when the second hand on her watch at the start of the deal is in a 2 second interval. Each of the three players will thus average one bluff every hour and a half. Let X1, X2, and X3 denote the number of big bluffs attempted in a given 6 hour interval by Player 1, Player 2, and Player 3, respectively. Each of these random variables is binomial with an expected value of 4, and a variance approaching 4. They are converging toward some limiting distribution, and that limiting distribution is called the Poisson distribution
They are converging toward some limiting distribution, and that limiting distribution is called the Poisson distribution. Unlike the binomial distribution which depends on two parameters, n and p, the Poisson distribution depends only on one parameter, λ, which is called the rate. In this example, λ = 4. The pmf of the Poisson random variable is f(k) = e-λλk/k!, for k=0,1,2,..., and for λ > 0, with the convention that 0!=1, and where e = 2.71828…. The Poisson random variable is the limit in distribution of the binomial distribution as n -> ∞ while np is held constant.
For a Poisson(λ) random variable X, E(X) = λ, and Var(X) = λ also. λ = rate. Example. Suppose in a certain casino jackpot hands are defined so that they tend to occur about once every 50,000 hands on average. If the casino deals approximately 10,000 hands per day, a) what are the expected value and standard deviation of the number of jackpot hands dealt in a 7 day period? b) How close are the answers using the binomial distribution and the Poisson approximation? Using the Poisson model, if X represents the number of jackpot hands dealt over this week, what are c)P(X = 5) and d) P(X = 5 | X > 1)? Answer. It is reasonable to assume that the outcomes on different hands are iid, and this applies to jackpot hands as well. In a 7 day period, approximately 70,000 hands are dealt, so X = the number of occurrences of jackpot hands is binomial(n=70,000, p=1/50,000). Thus a)E(X) = np = 1.4, and SD(X) = √(npq) = √(70,000 x 1/50,000 x 49,999/50,000) ~ 1.183204. b) Using the Poisson approximation, E(X) = λ = np = 1.4, and SD(X) = √λ ~ 1.183216. The Poisson model is a very close approximation in this case. Using the Poisson model with rate λ = 1.4, c) P(X=5) = e-1.4 1.45/5! ~ 1.105%. d) P(X = 5 | X > 1) = P(X = 5 and X > 1) ÷ P(X > 1) = P(X = 5) ÷ P(X>1) = [e-1.4 1.45/5!] ÷ [1 - e-1.4 1.40/0! – e-1.4 1.41/1!] ~ 2.71%.
4. Continuous random variables and their densities, p103-107. Density (or pdf = Probability Density Function) f(y): ∫B f(y) dy = P(X in B). Expected value, µ = E(X) = ∫ y f(y) dy. (= ∑ y P(y) for discrete X.) Variance, s2 = V(X) = E(X2) – m2. SD(X) = √V(X). For examples of pdfs, see p104, 106, and 107.
5. Examples: uniform, normal, standard normal & exponential random variables. * Uniform (0,1). See p107-109. f(y) = 1, for y in (0,1). µ = 0.5. s ~ 0.29. P(X is between 0.4 and 0.6) = ∫.4 .6 f(y) dy = ∫.4 .6 1 dy = 0.2. * Exponential (l). See p114. f(y) = le-ly, for y ≥ 0. E(X) = 1/l. SD(X) = 1/l. * Normal. pp 115-117. mean = µ, SD = s, f(y) = 1/√(2πs2) e-(y-µ)2/2s2. Symmetric around µ, 50% of the values are within 0.674 SDs of µ, 68.27% of the values are within 1 SD of µ, and 95% are within 1.96 SDs of µ. * Standard Normal. Normal with µ = 0, s = 1. See pp 117-118.
Standard normal density: 68.27% between -1.0 and 1.0 95% between -1.96 and 1.96
Exponential distribution, ch 6.4. Useful for modeling waiting times til something happens (like the geometric). pdf of an exponential random variable is f(y) = λ exp(- λ y), for y ≥ 0, and f(y) = 0 otherwise. If X is exponential with parameter λ, then E(X) = SD(X) = 1/λ If the total numbers of events in any disjoint time spans are independent, then these totals are Poisson random variables. If in addition the events are occurring at a constant rate λ, then the times between events, or interevent times, are exponential random variables with mean 1/λ. Example. Suppose you play 20 hands an hour, with each hand lasting exactly 3 minutes, and let X be the time in hours until the end of the first hand in which you are dealt pocket aces. Use the exponential distribution to approximate P(X ≤ 2) and compare with the exact solution using the geometric distribution.
Answer. Each hand takes 1/20 hours, and the probability of being dealt pocket aces on a particular hand is 1/221, so the rate λ = 1 in 221 hands = 1/(221/20) hours ~ 0.0905 per hour. Using the exponential model, P(X ≤ 2 hours) = 1 - exp(-2λ) ~ 16.556%. This is an approximation, however, since by assumption X is not continuous but must be an integer multiple of 3 minutes. Let Y = the number of hands you play until you are dealt pocket aces. Using the geometric distribution, P(X ≤ 2 hours) = P(Y ≤ 40 hands) = 1 - (220/221)40 ~ 16.590%. The survivor function for an exponential random variable is particularly simple: P(X > c) = ∫c∞ f(y)dy = ∫c∞ λ exp(-λ y)dy = -exp(-λ y)]c∞ = exp(-λ c). Like geometric random variables, exponential random variables have the memorylessness property: if X is exponential, then for any non-negative values a and b, P(X > a+b | X > a) = P(X > b). Thus, with an exponential (or geometric) random variable, if after a certain time you still have not observed the event you are waiting for, then the distribution of the future, additional waiting time until you observe the event is the same as the distribution of the unconditional time to observe the event to begin with.
6) Proj. B functions. FUNCTIONS FOR PROJECT B: straightdraw1 = function(x) ## returns 4 is there are 2 possibilities for a straight. ## returns 2 for a gutshot straight draw. ## returns 0 otherwise ## Note: returns 26 if you already have a straight! flushdraw1 = function(x) ## returns the max number of one suit ## (4 if flush draw, 5 if a flush already!) handeval = function(num1,suit1){ Straight-flush: return 8 million - 8,999,999 4 of a kind: return 7 million - 7,999,999 Full house: 6 million - 6,999,999, etc. . nada 1pr 2pr 3-kind straight flush full-house 4-kind str-flush . 0 1mil 2mil 3mil 4mil 5mil 6mil 7mil 8mil 9mil
7) Proj. B example. zelda = function(numattable1, crds1, board1, round1, currentbet, mychips1, pot1, roundbets, blinds1, chips1, ind1, dealer1, tablesleft){ a1 = 0 ## how much I'm gonna end up betting. Note that the default is zero. a2 = min(mychips1, currentbet) ## how much it costs to call if(round1 == 1){ ## pre-flop: ## AK: Make a big raise if nobody has yet. Otherwise call. ## AQ: call a small raise, or make one if nobody has yet. ## AJ, AT, KQ, KJ, QJ: call a tiny raise. ## A9, KT, K9, QT, JT, T9: call a tiny raise if in late position (within 2 of the dealer). ## Suited A2-AJ: call a small raise. ## 22-99: call a small raise. ## TT-KK: make a huge raise. If someone's raised huge already, then go all in. ## AA: make a small raise. If there's been a raise already, then double how much it is to you. a3 = 2*blinds1+1 ## how much a tiny raise would be a4 = 4*blinds1+1 ## how much a small raise would be a5 = max(8*blinds1,mychips1/4)+1 ## how much a big raise would be a6 = max(12*blinds1,mychips1/2)+1 ## how much a huge raise would be a7 = dealer1 - ind1 if(a7 < -.5) a7 = a7 + numattable1 ## your position: a7 = how many hands til you're dealer if((crds1[1,1] == 14) && (crds1[2,1] == 13)){ a1 = max(a2,a5) }
if((crds1[1,1] == 14) && (crds1[2,1] == 12)){ if(a2 < a4){ a1 = a4 } else if(a2 > a5){ a1 = 0 } else a1 = a2 } if(((crds1[1,1] == 14) && ((crds1[2,1] < 11.5) && (crds1[2,1] > 9.5))) || ((crds1[1,1] == 13) && (crds1[2,1] > 10.5)) || ((crds1[1,1] == 12) && (crds1[2,1] == 11))){ if(a2 < a3) a1 = a2 } if(((crds1[1,1] == 14) && (crds1[2,1] == 9)) || ((crds1[1,1] == 13) && ((crds1[2,1] == 10) || (crds1[2,1] == 9))) || ((crds1[1,1] == 12) && (crds1[2,1] == 10)) || ((crds1[1,1] == 11) && (crds1[2,1] == 10)) || ((crds1[1,1] == 10) && (crds1[2,2] == 9))){ if((a2 < a3) && (a7<2.5)) a1 = a2 } if((crds1[1,2] == crds1[2,2]) && (crds1[1,1] == 14) && (crds1[2,1] < 11.5)){ if(a2<a4) a1 = a2 ## Note: this trumps the previous section, since it comes later in the code. }
if((crds1[1,1] == crds1[2,1])){ ## pairs: if(crds1[1,1] < 9.5){ if(a2 < a4) a1 = a2 } else if(crds1[1,1] < 13.5){ if(a2<a5) a1 = a5 else a1 = mychips1 } else { if(a2 < blinds1 + .5) a1 = a4 else a1 = min(2*a2,mychips1) }}} if(round1 == 2){ ## post-flop: ## If there's a pair on the board and you don't have a set, then check/call up to small bet. ## Same thing if there's 3-of-a-kind on the board and you don't have a full house or more. ## If you have top pair or an overpair or two pairs or a set, make a big bet (call any bigger bet). ## Otherwise, if nobody's made even a small bet yet, then with prob. 20% make a big bluff bet. ## If you're the last to decide and nobody's bet yet, then increase this prob. to 50%. ## If you have an inside straight draw or flush draw then make a small bet (call any bigger bet). ## If you have a straight or better, then just call. ## Otherwise fold. a5 = min(sum(roundbets[,1]),mychips1) ## how much big bet would be (prev round's pot size) a6 = min(.5*sum(roundbets[,1]),mychips1) ## how much a small bet would be x = handeval(c(crds1[1:2,1], board1[1:3,1]), c(crds1[1:2,2], board1[1:3,2])) ## what you have x1 = handeval(c(board1[1:3,1]),c(board1[1:3,2])) ## what's on the board y = straightdraw1(c(crds1[1:2,1], board1[1:3,1]))
z = flushdraw1(c(crds1[1:2,2], board1[1:3,2])) topcard1 = max(board1[1:3,1]) a7 = runif(1) ## random number uniformly distributed between 0 and 1 a8 = (1:numattable1)[roundbets[,1] == roundbets[ind1,1]] ## others who can still bet with you ## The next 5 lines may seem weird, but the purpose is explained in the next comment: a9 = a8 - dealer1 for(i in 1:length(a9)) if(a9[i]<.5) a9[i] = a9[i] + numattable1 a10 = ind1 - dealer1 if(a10 < .5) a10 = a10 + numattable1 a11 = 2*(a10 == max(a9)) ## So a11 = 2 if you're last to decide; otherwise a11 = 0. if((x1 > 1000000) && (x < 3000000)){ if(a2 < a6) a1 = a2 } else if((x1 > 3000000) && (x < 6000000)){ if(a2 < a6) a1 = a2 } else if(x > 1000000 + 15^3*topcard1){ a1 = max(a5,a2) } else if((a2 < a6) && ((a7 < .20) || ((a7 < .50) && (a11>1)))){ a1 = a6 } if((y == 4) || (z == 4)) a1 = max(a6, a2) if(x > 4000000) a1 = a2 }
if(round1 == 3){ ## after turn: ## If there's a pair on the board and you don't have a set, then check/call up to small bet. ## Same thing if there's 3-of-a-kind on the board and you don't have a full house or more. ## Otherwise, if you have top pair or better, go all in. ## If you had top pair or overpair but now don't, then check/call a medium bet but fold to more. ## If you have an inside straight draw or flush draw then check/call a medium bet as well. ## Otherwise check/fold. a6 = min(1/3*sum(roundbets[,1:2]),mychips1) ## small bet (1/3 of prev round's pot size) a5 = min(.75*sum(roundbets[,1:2]),mychips1) ## medium bet (3/4 of prev round's pot) x = handeval(c(crds1[1:2,1], board1[1:4,1]), c(crds1[1:2,2], board1[1:4,2])) ## what you have x1 = handeval(c(board1[1:4,1]),c(board1[1:4,2])) ## what's on the board y = straightdraw1(c(crds1[1:2,1], board1[1:4,1])) z = flushdraw1(c(crds1[1:2,2], board1[1:4,2])) topcard1 = max(board1[1:4,1]) oldtopcard1 = max(board1[1:3,1]) if((x1 > 1000000) && (x < 3000000)){ if(a2 < a6) a1 = a2 } else if((x1 > 3000000) && (x < 6000000)){ if(a2 < a6) a1 = a2 } else if(x > 1000000 + 15^3*topcard1){ a1 = mychips1} else if(x > 1000000 + 15^3*oldtopcard1){ if(a2 < a5) a1 = a2 } else if((y == 4) || (z == 4)){ if(a2 < a5) a1 = a2 } }
if(round1 == 4){ ## after river: ## If there's a pair on the board and you don't have a set, then check/call up to small bet. ## Same thing if there's 3-of-a-kind on the board and you don't have a full house or more. ## Otherwise, if you have two pairs or better, go all in. ## If you have one pair, then check/call a small bet. ## With nothing, go all-in with probability 10%; otherwise check/fold. a6 = .45+runif(1)/10 ## random number between .45 and .55 a5 = min(a6*sum(roundbets[,1:3]),mychips1) ## small bet~ 1/2 of pot size; varies randomly x = handeval(c(crds1[1:2,1], board1[1:5,1]), c(crds1[1:2,2], board1[1:5,2])) x1 = handeval(c(board1[1:5,1]),c(board1[1:5,2])) ## what's on the board if((x1 > 1000000) && (x < 3000000)){ if(a2 < a5) a1 = a2 } else if((x1 > 3000000) && (x < 6000000)){ if(a2 < a5) a1 = a2 } else if(x > 2000000){ a1 = mychips1 } else if(x > 1000000){ if(a2 < a5) a1 = a2 } else if(runif(1)<.10){ a1 = mychips1} } round(a1) } ## end of zelda