should be on the RNG posts....but

Discuss proper hold strategies and "advantage play" and ask questions about how to improve your play.
Webman
Video Poker Master
Posts: 5175
Joined: Thu Dec 28, 2017 3:11 pm

Re: should be on the RNG posts....but

Post by Webman »


OK, CD. In simple terms, then, when you are playing a multi-line game, like ten-way TDB, how does it handle not duplicating cards that have already been used on the deal when you replace them on the draw? You simply select cards at random from the remaining cards instead of all 52. After the deal, the deck of 47 remaining cards is copied to your 10 draw hands.  Then the draw on each deck is handled separately.

BillyJoe
Video Poker Master
Posts: 3198
Joined: Sat Aug 23, 2008 2:00 pm

Post by BillyJoe »

Thanks, Webman. I wasn't sure if it started with only the 47 "eligible" cards, or whether it chose a card, compared it to what was dealt, and either accepted or rejected it. That still doesn't explain, though, why the particular card you were looking to draw always shows up in the next dealt hand.  

cddenver
Video Poker Master
Posts: 2269
Joined: Tue Mar 13, 2007 9:54 pm

Post by cddenver »

OK, CD. In simple terms, then, when you are playing a multi-line game, like ten-way TDB, how does it handle not duplicating cards that have already been used on the deal when you replace them on the draw?


 
There are several ways that can be done.  In my own simulation I have a table that stores a selection value of "True" or "False" for all 52 cards, and set all values to "False" at the start of a hand.  After I get a number from the RNG and convert it to a card value I set the selection value for that card to "True".  If the selection value for the card is already "True" I simply continue getting numbers from the RNG until I get a card value with a selection value of "False".  I then set that selection value to "True".  That process is done until I have five cards selected.  On each line of a multiline game the dealt cards are the same, so I keep those and then generate additional card values for each line, using the same process to make sure that the new values don't match any of the five dealt cards or prior drawn cards for that line. 

ginxxxx
Senior Member
Posts: 266
Joined: Thu Aug 31, 2006 4:30 pm

Post by ginxxxx »


My usual metaphor for an RNG is to think of painting a card (or number) on every inch of an interstate going from the east coast to the west coast. The RNG is a fast moving car zooming over the cards. When you press deal the car stops immediately and selects the next five cards and then takes off again. When you select your cards and press draw the car stops again and selects whatever cards it finds. Any difference in timing will result in the car stopping at a different spot.




 
The "seed" is where you place the car to start out. For one seed it might be in St. Louis, another might be Denver and so on. You can see that a different sequence of cards would be available for each different seed.Thank you for this excellent  description of RNG!This sort of thing explains why some people's heads explode!

cddenver
Video Poker Master
Posts: 2269
Joined: Tue Mar 13, 2007 9:54 pm

Post by cddenver »

Another issue has been ignored here. An RNG generally has a range of several billion values. CD's example needs a bigger decimal precision. 

 
Exactly right, and thanks for pointing that out.   Your reply reminded me of a question I've been meaning to ask.  I wrote a VP analysis tool many years ago and I'm now redoing it in Excel.  Part of it allows me to play out hands to look at actual runs of certain hands like RFs.  I do that with the standard Rnd() function in VBA, which returns single precision values.
 
In the case of RFs, the minimum interval between RFs always comes out to 119 hands, and the maximum interval always comes out to 326,120 hands.  There are also many duplicate intervals.  That's over a sample of 5,000 RFs, determining hand results not by actually dealing/drawing cards, but by using one hand result value from the RNG.  In the case of RFs that's approximately .000025 (varies slightly by game type but that particular number works out to 1/40,000).  I've been assuming that the reason is the limit in precision of that particular RNG.  Is there a way around it that doesn't involve me having to buy some sort of statistical add-in package?  Or redoing that simulation to actually play out millions of hands, which takes forever when using macros?
 

Almost anything we do playing VP changes our timing. Even a cough, sneeze or scratching an itch will change our results.

 
Or a player's caffeine index at the time of play!   

shadowman
Video Poker Master
Posts: 3587
Joined: Mon Oct 23, 2006 5:42 pm

Post by shadowman »

  
Exactly right, and thanks for pointing that out.   Your reply reminded me of a question I've been meaning to ask.  I wrote a VP analysis tool many years ago and I'm now redoing it in Excel.  Part of it allows me to play out hands to look at actual runs of certain hands like RFs.  I do that with the standard Rnd() function in VBA, which returns single precision values.
 
In the case of RFs, the minimum interval between RFs always comes out to 119 hands, and the maximum interval always comes out to 326,120 hands.  There are also many duplicate intervals.  That's over a sample of 5,000 RFs, determining hand results not by actually dealing/drawing cards, but by using one hand result value from the RNG.  In the case of RFs that's approximately .000025 (varies slightly by game type but that particular number works out to 1/40,000).  I've been assuming that the reason is the limit in precision of that particular RNG.  Is there a way around it that doesn't involve me having to buy some sort of statistical add-in package?  Or redoing that simulation to actually play out millions of hands, which takes forever when using macros?


 
I did something similar in C++ but I used double precision and did not have a problem. I used an RNG I downloaded off the web. That's how I simulated falala's system. Easy to run through millions of hands in a few seconds.
 
I finally have a copy of Excel on my new system but I haven't started using it yet. So, can't help with anything there. I think new2vp uses excel quite a bit.

New2vp
Video Poker Master
Posts: 1850
Joined: Mon Sep 11, 2006 4:02 am

Post by New2vp »



Hey cd,  As you can probably tell, you have run into a problem that is caused by the "period" of the random number generator in Excel or VBA  (the number of pseudo-random numbers after which you get repetition) being too small.For 5000 royal flushes, you need roughly 5000 x 40000 = 200 million numbers.  I'm not certain of the period of the rand() function, but it may well be only a little over 4 million (2^32 -1).  Hence, you will get repeating values when you try to get more than this amount of random numbers.One later RNG without this problem is the Mersenne Twister.  Its period is greater than 4 x 10^6001, more than enough to prevent repeats on anything you might try to do.  Try googling Mersenne Twister for Excel.  I didn't try to download this but I think there is a free download at http://www.financial-risk-manager.com/r ... l#mt19937I couldn't tell if you needed Office 2007 to run this or not.Another famous name in modern RNGs is George Marsaglia.  I have used his KISS+MONSTER algorithm using a language called GAUSS.  His RNG has a period of 10^8859.  I'm unaware of any attempts to make this one available to Excel.  And I don't know how to code it directly.  Many simple RNGS require only 2 or 3 lines of code with one number being carried over to calculate the next random number in line; Marsaglia's Monster requires a calculation of a new column of 500 numbers to determine each subsequent random number.It's relatively impossible to imagine how long these periods are.  One thought experiment is to imagine that the universe is packed with super computers the size of atoms, with each one producing a trillion trillion random numbers per second.  Since there is quite a bit of empty space in the universe, in this example there would be more computers than there are atoms in the universe.  Ignoring coordination between the computers (and just about any other practical consideration), if these machines had been producing random numbers since the beginning of time (14 billion years ago), together they would have produced "only" 10^152 random numbers.  So the period in either case above will be overkill on any experiment that any of us could do in our lifetimes.Now, on another note, you really do not need random number generation to attack the problem of determining what are reasonable ranges of hands between royals.  There are some mathematical and statistical formulae that allow direct calculation of just about anything you would want to know.  All you need to know is p = probability of a royal and some value x = probability of attaining a royal in less than or equal to n hands.For example, with computer perfect strategy on 9/6 Jacks or Better, we have p = 493,512,264/19,933,230,517,200 = 0.0000247582680375947.The formula for the probability that a royal will first appear on the jth hand is p x (1 - p)^(j - 1).  Thus, for the 28,000th hand, the probability is  0.00001237829043844.To find the probability of a royal somewhere between the 1st and nth hands, inclusively, the sum of probabilities turns out to be 1 - (1 - p)^n.  For example, the probability of getting a royal sometime in the next 10,000 hands is 0.219316721970159.If you want the probability of getting a royal on or after the nth hand, the formula is (1 - p)^n - 1.  For example, the probability of getting a royal on or after the 10,000th hand is 0.78070260687424.These two numbers add up to slightly more than one because they both include the probability of getting a royal on exactly the 10,000th hand:  0.0000193288444.If you want to start with a given probability and find the number of hands it takes to get that probability, you need to use logarithms.  For example, if we would like to know what range we can expect 1/2 the royals to fall in, we can find the n for x = 0.25 and for x = 0.75.n = ln (1 - x) / ln (1 - p) or n = 11619.493 for x = 0.25 and n = 55992.495 for x = 0.75.  This can be interpreted to mean that about 50% of the time, we will find that the number of hands until the next royal will be between 11619 and 55992.You can directly find the probability that the next royal will appear between the mth hand and the nth hand by using the formula:(1 - p)^(m - 1) - (1 - p)^n, so checking for m = 11619 and n = 55992, we find the probability to be 0.500024651648677, which checks with what we found in the last paragraph.The over/under for the next royal in 9/6 JoB is 27996.5 with about half the royals occurring on or before the 27,996th hand and the other half on or after the 27,997th hand.  Use x = .5, p = 0.0000247582680375947, and n = ln (1 - x) / ln (1 - p) .Other confidence intervals for royals using these formulae are:




5393
83989
75%


2072
120998
90%


1023
148994
95%


202
213999
99%


101
241996
99.5%


20
307001
99.9%


4
372006
99.98%


2
400002
99.99%

This means, for example, that 3/4 of royals will occur between the 5393rd hand and the 83,989th hand.  The next to last row can compare to your simulation of 5000 royals (because 1/(1 - .9998) = 5000).  Here we see that the limits are slightly more than 4 to slightly more than 372,006 before rounding to the nearest integer.Sorry, I don't intentionally want to make any more heads explode!  Hope some of this was helpful.

cddenver
Video Poker Master
Posts: 2269
Joined: Tue Mar 13, 2007 9:54 pm

Post by cddenver »




I did something similar in C++ but I used double precision and did not have a problem. I used an RNG I downloaded off the web. That's how I simulated falala's system. Easy to run through millions of hands in a few seconds.
 
I finally have a copy of Excel on my new system but I haven't started using it yet. So, can't help with anything there. I think new2vp uses excel quite a bit.
 
The Excel reference doesn't mention the precision of the RAND() spreadsheet function, and I assume it's the same as the VBA Rnd() function.  I have some other development software that supports double precision RNG, but I think the single precision RAND() and Rnd() functions are it for Excel.  When I first noticed the problem I did some googling and saw that RAND() and Rnd() aren't regarded highly by statisticians for whatever they consider to be serious work.  I can't give details because most of them are in academic papers that the authors/publishers want $$$'s for.
 
In a practical sense it doesn't affect what I'm doing, but it does look a little funny when I go into the raw numbers afterwards and look at them.  The same thing happens to a lesser degree when I play out hand intervals for different kinds of quads.

BOOPSAHOY
Video Poker Master
Posts: 1625
Joined: Thu Sep 14, 2006 5:20 pm

Post by BOOPSAHOY »

Hey ginxxxx-guess what this is? @$&^$$&&%$ Thats my head exploding!

marie meijer
Video Poker Master
Posts: 1598
Joined: Sun Apr 22, 2007 12:45 pm

Post by marie meijer »





Post Reply