From: jacobs@cs.utah.edu (Steven R Jacobs)
Subject: Re: Keno and Bingo
In-reply-to: ov@head-cfa.harvard.edu's message of 16 Dec 92 13:28:24 GMT
Organization: University of Utah CS Dept
	<1gmcnoINNkt9@agate.berkeley.edu>
	<1992Dec16.132824.19267@head-cfa.harvard.edu>
Date: 16 Dec 92 09:09:54


OK, Keno fans.  Here's a program to compute the odds in Keno.  You'll have
to supply the playoff schedule and compute the expectation yourself, or
modify the program to handle it for you.  For those of you who are not
inclined to compile the program yourself, the output of the program is
also included.

Note however, that this program assumes uniform stupidity on the part
of the ping-pong balls.  Any bias due to "ball competition" is unaccounted
for :-)

No flames about the program, this sucker is *old* code.

/*--------------------------- keno.c cut here ---------------------*/
#include <stdio.h>

main()
{
int H, K;
double p, keno();

   for (K = 1; K <= 15; K++)
      {
      printf("Hit | %2d spots played\n", K);
      puts("----+-------------------------------------");
      for (H = 0; H <= K; H++)
	 {
	 p = keno(K, H);
	 printf(" %2d | %16.3f\t%16.14f\n", H, 1.0 / p, p);
	 }
      putc('\n', stdout);
      }
}

double keno(k, h)
int k, h;
{
double result;
int i;

   result = 1.0;
   for (i = h; i; i--)
      result *= (21 - i)/((double) i);
   for (i = k; i; i--)
      result *= ((double) i)/(81 - i);
   for (i = k - h; i; i--)
      result *= (61 - i)/((double) i);
   return (result);
}
/*--------------------------- keno.c cut here ---------------------*/

   
Hit |  1 spots played
----+-------------------------------------
  0 |            1.333	0.75000000000000
  1 |            4.000	0.25000000000000

Hit |  2 spots played
----+-------------------------------------
  0 |            1.785	0.56012658227848
  1 |            2.633	0.37974683544304
  2 |           16.632	0.06012658227848

Hit |  3 spots played
----+-------------------------------------
  0 |            2.401	0.41650438169426
  1 |            2.321	0.43086660175268
  2 |            7.207	0.13875365141188
  3 |           72.070	0.01387536514119

Hit |  4 spots played
----+-------------------------------------
  0 |            3.243	0.30832142541003
  1 |            2.311	0.43273182513689
  2 |            4.703	0.21263546580002
  3 |           23.123	0.04324789134916
  4 |          326.436	0.00306339230390

Hit |  5 spots played
----+-------------------------------------
  0 |            4.402	0.22718420819687
  1 |            2.465	0.40568608606583
  2 |            3.697	0.27045739071056
  3 |           11.914	0.08393505228948
  4 |           82.697	0.01209233804171
  5 |         1550.569	0.00064492469556

Hit |  6 spots played
----+-------------------------------------
  0 |            6.002	0.16660175267770
  1 |            2.751	0.36349473311499
  2 |            3.243	0.30832142541003
  3 |            7.703	0.12981954754107
  4 |           35.041	0.02853791777842
  5 |          323.035	0.00309563853868
  6 |         7752.843	0.00012898493911

Hit |  7 spots played
----+-------------------------------------
  0 |            8.225	0.12157425195400
  1 |            3.173	0.31519250506592
  2 |            3.061	0.32665405070468
  3 |            5.715	0.17499324144894
  4 |           19.160	0.05219096674793
  5 |          115.761	0.00863850484104
  6 |         1365.977	0.00073207668144
  7 |        40979.314	0.00002440255605

Hit |  8 spots played
----+-------------------------------------
  0 |           11.329	0.08826623772003
  1 |            3.753	0.26646411387178
  2 |            3.047	0.32814562171247
  3 |            4.656	0.21478622512089
  4 |           12.269	0.08150370149677
  5 |           54.637	0.01830258559927
  6 |          422.527	0.00236671365508
  7 |         6232.271	0.00016045516306
  8 |       230114.608	0.00000434566067

Hit |  9 spots played
----+-------------------------------------
  0 |           15.687	0.06374783835335
  1 |            4.532	0.22066559430007
  2 |            3.160	0.31642613522274
  3 |            4.063	0.24610921628435
  4 |            8.764	0.11410518209547
  5 |           30.673	0.03260148059871
  6 |          174.839	0.00571955799977
  7 |         1690.107	0.00059167841377
  8 |        30681.948	0.00003259245500
  9 |      1380687.647	0.00000072427678

Hit | 10 spots played
----+-------------------------------------
  0 |           21.838	0.04579070078903
  1 |            5.569	0.17957137564325
  2 |            3.387	0.29525678110572
  3 |            3.740	0.26740236779386
  4 |            6.788	0.14731889707162
  5 |           19.445	0.05142768770500
  6 |           87.113	0.01147939457701
  7 |          620.677	0.00161114309853
  8 |         7384.469	0.00013541935526
  9 |       163381.372	0.00000612064883
 10 |      8911711.176	0.00000011221190

Hit | 11 spots played
----+-------------------------------------
  0 |           30.574	0.03270764342073
  1 |            6.949	0.14391363105123
  2 |            3.730	0.26807441078170
  3 |            3.592	0.27838496504254
  4 |            5.600	0.17858658134804
  5 |           13.499	0.07408035967030
  6 |           49.496	0.02020373445554
  7 |          277.176	0.00360780972420
  8 |         2430.625	0.00041141689837
  9 |        35244.056	0.00002837357920
 10 |       945181.488	0.00000105799787
 11 |     62381978.235	0.00000001603027

Hit | 12 spots played
----+-------------------------------------
  0 |           43.053	0.02322716706690
  1 |            8.790	0.11376571624603
  2 |            4.206	0.23777034695421
  3 |            3.575	0.27972981994613
  4 |            4.860	0.20576280024883
  5 |           10.062	0.09938731483717
  6 |           31.047	0.03220885203057
  7 |          142.300	0.00702738589758
  8 |          980.778	0.00101959840032
  9 |        10482.068	0.00009540101991
 10 |       184230.290	0.00000542798906
 11 |      5978272.914	0.00000016727239
 12 |    478261833.137	0.00000000209090

Hit | 13 spots played
----+-------------------------------------
  0 |           60.992	0.01639564734134
  1 |           11.260	0.08880975643226
  2 |            4.840	0.20661861700566
  3 |            3.667	0.27273657444747
  4 |            4.400	0.22728047870623
  5 |            7.944	0.12587841897576
  6 |           21.052	0.04750129017953
  7 |           81.201	0.01231514930580
  8 |          458.056	0.00218314010421
  9 |         3847.669	0.00025989763145
 10 |        49844.800	0.00002006227331
 11 |      1060032.746	0.00000094336708
 12 |     41694621.350	0.00000002398391
 13 |   4065225581.667	0.00000000024599

Hit | 14 spots played
----+-------------------------------------
  0 |           86.946	0.01150142425437
  1 |           14.594	0.06851912321754
  2 |            5.672	0.17629399411180
  3 |            3.860	0.25904423624590
  4 |            4.129	0.24220636088992
  5 |            6.580	0.15197261859760
  6 |           15.207	0.06575738304704
  7 |           50.375	0.01985128544816
  8 |          239.141	0.00418163651802
  9 |         1644.093	0.00060823803898
 10 |        16739.858	0.00005973766454
 11 |       262397.268	0.00000381101528
 12 |      6764018.476	0.00000014784111
 13 |    324250135.681	0.00000000308404
 14 |  38910016281.667	0.00000000002570

Hit | 15 spots played
----+-------------------------------------
  0 |          124.748	0.00801614417729
  1 |           19.128	0.05227920115624
  2 |            6.760	0.14793901603787
  3 |            4.160	0.24040090106154
  4 |            3.997	0.25021318273752
  5 |            5.677	0.17615008064721
  6 |           11.581	0.08634807874863
  7 |           33.456	0.02988971956683
  8 |          136.399	0.00733144064847
  9 |          789.165	0.00126716258122
 10 |         6576.373	0.00015205950975
 11 |        81020.911	0.00001234249267
 12 |      1539397.308	0.00000064960488
 13 |     48362732.102	0.00000002067708
 14 |   2853401193.989	0.00000000035046
 15 | 428010179098.333	0.00000000000234
--
Steve Jacobs  ({bellcore,hplabs,uunet}!utah-cs!jacobs, jacobs@cs.utah.edu)
"Don't worry, I just have these harmless pocket rockets...."
Newsgroups: rec.gambling