# Problem on the job

Hi, I am a math developer for a gaming technology company, and need the assistance of a math/computer science guru.

We have a standard bingo card, with five rows, five columns, and a free space in the center. Column 1 contains 5 integers chosen at random from the set 1 thru 15. Column 2 ... 16-30. Column 3 contains 4 integers ... 31 thru 45. Column 4 contains 5 integers ... 46 thru 60. Column 5 ... 61 thru 75. This game is a slot machine version of bingo, where only one bingo card can used per game, and every card eventually achieves a bingo.

The Draw # is defined as the number of balls drawn when the player FIRST arrives at bingo. For instance if a player hits bingo after 4 numbers have been called, then the Draw # is 4.

If a number is called such that the player has this number on their card, then we call this a daub. Important note: A player can have only so many daubs before a bingo is reached.

The Pay Group # is defined to be the ones digit of the integer that results when the four "corner" numbers are summed together. For instance, if the four corner numbers are 6,12, 68, 71, then the pay group is 7. Important note: Column 1 can only contain integers contained in the set 1 thru 15, Column 5 ... 61 thru 75.

The pay table used to calculate winnings, if any, is based on three factors. Factor #1) The Draw #, Factor #2) The number of daubs, Factor #3) The Pay Group #. For instance if the Draw # is 9, number of daubs is 4, and the paygroup is 7, then the player receives a 2 to 1 return on their bet. Important Note- The paytable details are not important to this problem, the 3 factors used in determining pay are important.

Heres the problem: I need to calculate the probability of the occurence of each event. I have a list of all the events, and I can provide it, if necessary. For instance, I need to calculate the probabilities of the events,

5 draws, 4 daubs, Paygroup: 0
7 draws, 6 daubs, Paygroup: 0
11 draws, 9 daubs, Paygroup: 0
.
.
.

Any ideas on how to calculate?

Borek
Mentor
Without getting into details of your problem, sound to me like it can be done just by simulation and brute force - write a program that simulates zillions of games (with all necessary conditions) and see how often you get each event. That's what the probability is about, isn't it?

chiro
Hey Mark Morse and welcome to the forum.

One way that is easy to understand and easy to code up is to use what is known as simulation. Simulation is a fancy way of saying "let's use an appropriate pseudo-random number generator to obtain a distribution and hence a probability".

What you should do is simulate your process that corresponds to the distribution of each square of the bingo board and then using simple transformations, get the distribution (all of these are simulated) of the draws, daubs, and pay group.

I can run through this in more detail, but essentially the idea is that you turn your bingo board into a number of random variables and then do a lot of simulations to get an accurate enough distribution.

So as an example for the first row you can pick from 1-15. So what you would do is you would do five random simulations for the row where the next simulation takes out the values you got before (this is called sampling without replacement). You do the same sort of thing for the other rows.

But then you do the whole procedure in the above paragraph many thousands (tens of thousands) of times to obtain a distribution for each cell on your board. Once you have this you can then add some simple functionality to get your daub distribution, draw distribution and payout distribution.

The simulation itself might take a little while but the speed of computers is fast enough that if you use the right code, you can generate all distributions for the board, the daub, the draw and the payout possibly overnight with a decent computer (and probably a lot less, as in a few minutes or 10/20 minutes).

Thank you for the replies. My CS department ran the simulations, and they generated probabilities that differ from what the math department came up with. The extent of the differences is unacceptable. In order to get approval from the gaming control board, the simulations need to fall within a certain range of the math-based calculations. Chiro, Borek, any thoughts on how to calculate this mathematically? (a program can be used to calculate the number of ways to get a bingo given "n" daubs.)

Stephen Tashi
Both simulation programmers and mathematical reasoners can easily make mistakes in this sort of problem. I suggest having the math and CS people calculate special cases and compare answers on those. That might isolate the errors in programming or calculation. For example, look at the case when the numbers on a card are a given set of numbers in a given set of places and only vary the numbers picked by the bingo caller. Or specialize even further and assume a particular 5 numbers have been called by the bingo caller in a particular order and only vary the remaining numbers that are picked at random.

If your CS people are good at simulations, they will run tests on their random number generator. It can be a source of insidious problems. Even if an academic paper has been published saying version 4.1.32 of the generator is above reproach, if you upgrade to version 4.1.33, you'd better test it again.

chiro
Thank you for the replies. My CS department ran the simulations, and they generated probabilities that differ from what the math department came up with. The extent of the differences is unacceptable. In order to get approval from the gaming control board, the simulations need to fall within a certain range of the math-based calculations. Chiro, Borek, any thoughts on how to calculate this mathematically? (a program can be used to calculate the number of ways to get a bingo given "n" daubs.)

You can do it analytically by using a sample without replacement distribution.

Take a look at this for modelling every single row:

http://en.wikipedia.org/wiki/Hypergeometric_distribution#Multivariate_hypergeometric_distribution

Stephen Tashi
Mark,

It's usually easier to criticize a proposed solution than to find a solution. Given the limited time that mathematical internet strangers are willing to devote to someone else's questions, I think you'll get more substantial help on the forum if you reveal the details of your mathematicians' work - or at least some of it.

mfb
Mentor
I think you can reduce the complexity a lot, if 1 to 75 all have the same probability to get drawn:

- the used numbers in each group (1-15, ...) do not matter for the bingo probability, you can easily fix them (for example "first column on the board is 1 2 3 4 5").
- the pay group is independent of the chances to win, you can calculate the relative probability to get a specific pay group independently. This can be done in an analytic way or with a quick simulation.
- the probability to get n daubs with m draws is given by the hypergeometric distribution
- the probability to get a bingo depends on the number of daubs only. How do you treat the empty square? I think I would use a simulation here, this does not require many boards and can be done quickly.

To put it together:
"11 draws, 9 daubs, Paygroup: 0"
=> use your calculated value to be in paygroup 0, multiply with your calculated probability to win with the 9th daub (and not earlier), multiply with the probability to get 9 daubs in 11 (but not less) draws.