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