home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13585 < prev    next >
Encoding:
Text File  |  1992-09-13  |  2.0 KB  |  59 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!news.funet.fi!funic!nntp.hut.fi!nntp.hut.fi!Hannu.Nyman
  3. From: Hannu.Nyman@hut.fi (Hannu Nyman)
  4. Subject: Re: FULL HOUSE
  5. In-Reply-To: ppc1@cec1.wustl.edu's message of Sun, 13 Sep 1992 14:43:15 GMT
  6. Message-ID: <HANNU.NYMAN.92Sep13232800@vipunen.hut.fi>
  7. Sender: usenet@nntp.hut.fi (Usenet pseudouser id)
  8. Nntp-Posting-Host: vipunen.hut.fi
  9. Reply-To: Hannu.Nyman@hut.fi
  10. Organization: Helsinki University of Technology, Finland
  11. References: <1992Sep13.144315.24892@wuecl.wustl.edu>
  12. Date: 13 Sep 92 23:28:00
  13. Lines: 44
  14.  
  15. In article <1992Sep13.144315.24892@wuecl.wustl.edu>, ppc1@cec1.wustl.edu (Peter Pui Tak Chiu) writes:
  16.  
  17. > i am trying to find the probability of getting a hand of full house from a
  18. > shuffled deck of 52 cards.
  19. >
  20. > theoretically, the probability (i think) is:
  21. >
  22. >         (13 * 4C2) * (12 * 4C3)
  23. >         -----------------------  =  0.001440576
  24. >                  52C5
  25. >
  26. > but i wrote a c program to calculate this probability and the results turn
  27. > out to be very different.
  28.  
  29. [DELETED]
  30.  
  31. > 5480000 0.00420967
  32. > 5490000 0.00420765
  33. > 5500000 0.004208  ... this means after 5500000 trials, the prob. is 0.004208
  34. >
  35. >
  36. > from these results, i conclude that the probability would be pretty much around
  37. > 0.00421 which is very different from the theoretical value.
  38. >
  39. > does anyone know why???
  40.  
  41. [DELETED]
  42.  
  43. > void init(){
  44. > for(int i=0;i<5;i++)hand[i]=rand()%13;    // deal the cards
  45. > }
  46.  
  47. Here is your mistake: You are drawing cards from an infinite deck. The
  48. probability of getting e.g. an ace after your first card was one is no
  49. more 1/13, it is 3/51 and so on... You should declare a proper deck of
  50. 52 cards and draw cards from it, marking those cards you already have
  51. got so that you can't have two aces of clubs at the same hand!
  52.  
  53. Hannu Nyman
  54. --
  55. +--------------------+---------------------------+----------------------+
  56. I    Hannu Nyman     I   Hannu.Nyman@hut.fi      I  Errare humanum est  I
  57. I                    I   hnyman@vipunen.hut.fi   I                      I
  58. +--------------------+---------------------------+----------------------+
  59.