Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Keno is a popular lottery game that is available with all of the larger casino softwares. The player is given a ticket with 70 numbers on it. He picks 1 to 11 numbers on the ticket. 20 winning numbers are selected randomly. The more of the player's picks that are selected, the bigger the payout.

In Sweden, my home country, Svenska Spel (a state owned company) offers the following \begin{array}{c|c|c|} \text{Number of Correct Guesses}&\text{Return} &\text{Average Chance of Winning} \\ \hline 11 & 5000000 &\text{See below} \\ \hline 10 &125000 & \\ \hline9 & 3000 & \\ \hline8 & 300 & \\ \hline 7 & 30 & \\ \hline 6 & 10 & \\ \hline 5 & 5 & \\ \hline 4 & 0 & \\ \hline 3 & 0 & \\ \hline 2 &0 & \\ \hline 1 & 0 & \\ \hline 0 & 0 & \text{1 to 6.2} \end{array}

What I would like to do is to calculate the probability to obtain $0,1,2,\dots, 11$ right guesses on Keno 11 and compare it to Svenska spel. In addition, I would like to plot this result using histograms.

My Take

What I have done is to define the hypergeometric probability distribution function as:

    Urn[good_, bad_, draws_, need_] := ({{good},{need}}) ({{bad},{draws - need}})/
({{good + bad},{draws}})

I have then used this to calculate the KenoOdds using the following code:

 KenoOdds = 
 Table[MatrixForm[
   Table[{g, k, Round[1/N[Urn[g, 70, 20, k]]] - 1}, {k, 0, g}]], {g, 
   4, 11}]

The problem is that the first code does not work; all I receive is this message "An unknown box name (Hold) was sent as the BoxForm for the expression. Check the format rules for the expression." H

share|improve this question

closed as off-topic by Szabolcs, Sjoerd C. de Vries, m_goldberg, bobthechemist, rm -rf Jan 16 at 4:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, Sjoerd C. de Vries, m_goldberg, bobthechemist, rm -rf
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Hmm... seems to work here. I do get some divide by zero messages, but those are unrelated to your question. It seems like some hidden/invisible characters might have crept in to your cell. Try deleting it and copy-pasting what you have written here. Remember to clear definitions or start a fresh kernel. –  rm -rf Jan 14 at 19:28
1  
You are inputting column matrices when you are likely looking for Binomial. Please look it up in the docs. You need to provide precise and correct syntax for computers to understand ... –  Szabolcs Jan 14 at 19:28
    
Haha, is this the first lab in Probability theory I, at Stockholm Uni? –  Paxinum Jan 15 at 22:14

2 Answers 2

You probably input something that looks like $$ \frac{\left( \begin{array}{c} \text{good} \\ \text{need} \\ \end{array} \right) \left( \begin{array}{c} \text{bad} \\ \text{draws}-\text{need} \\ \end{array} \right)}{\left( \begin{array}{c} \text{bad}+\text{good} \\ \text{draws} \\ \end{array} \right)} $$

These however were not interpreted as binomial coefficients, but as column vectors (2 by 1 matrices). You can see this from the form of the expression you pasted here.

You are likely looking for

(Binomial[good, need] Binomial[bad, draws - need])/Binomial[good + bad, draws]

Mathematica does allow you to input something that looks like traditional mathematical notation and it can interpret some of it, but this is not reliable. Your case is a perfect example of why. Mathematica does in fact give a warning before evaluating a TraditionalForm input. Generally, TraditionalForm is more useful for reading output than for inputting new expressions.

share|improve this answer

monte carlo approach..

n = 1000000;
nchoice = 11;
nball = 70;
draws = 20;
{#[[1]], N[ #[[2]]/n]} & /@ Sort@Tally@Table[
         Length@Intersection[
                 RandomSample[Range[nball], nchoice],
                 RandomSample[Range[nball], draws]
                            ], {n}]

Compare with Szabolcs' formula (which is just a tad faster.. )

   0, 0.017371 0.0172627
   1, 0.094738 0.0949448
   2, 0.219235 0.219994
   3, 0.283973 0.282849
   4, 0.223563 0.223648
   5, 0.113827 0.113857
   6, 0.037821 0.0379524
   7, 0.008278 0.00825053
   8, 0.001096  0.00114103
   9, 0.00009 0.0000950859
   10, 8.*10^-6 4.26916*10^-6
   11  ---       7.76212*10^-8
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.