Thread View: sci.math.stat
2 messages
2 total messages
Started by Peter Pui Tak Chiu
Sun, 13 Sep 1992 14:33
FULL HOUSE
Author: Peter Pui Tak Chiu
Date: Sun, 13 Sep 1992 14:33
Date: Sun, 13 Sep 1992 14:33
89 lines
2836 bytes
2836 bytes
hi everyone,
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.
here is part of the results i have:
* the first column denotes the number of trials
* the second column denotes the probability obtained so far
5400000 0.00420815
5410000 0.00420758
5420000 0.00420867
5430000 0.00420829
5440000 0.00420937
5450000 0.00421046
5460000 0.00421154
5470000 0.00420987
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???
i have included the program i wrote. it is written in C++ and is very crude...
please try it and give me some feedback.
thanx a lot!
pete
// To calculate the probability of getting a full house
#include <iostream.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
int BAD,hand[5]; // BAD when the hand dealt is illegal
// e.g. 5 of the same kind.
// hand is an array holding the cards dealt
long COUNTER=0, GOOD=0; // COUNTER = # of trials
// GOOD = # of full house dealt
void init(){
for(int i=0;i<5;i++)hand[i]=rand()%13; // deal the cards
}
int fullhouse(){ // determine if fullhouse or illegal
int counter[13],flag3=0,flag2=0;
BAD=0;
for(int i=0;i<13;i++)counter[i]=0;
for(i=0;i<5;i++)counter[hand[i]]++;
for(i=0;i<13;i++){
if(counter[i]==3)flag3++; // detect for 3 of a kind
if(counter[i]==2)flag2++; // detect for a pair
if(counter[i]>4)BAD=1;} // detect for a bad hand
return((flag3==1) && (flag2==1));
}
main(){
srand((unsigned)time(NULL)); // initialize random seed
while(1){
init(); // deal the cards
if(fullhouse())GOOD++; // if a FULLHOUSE is dealt, increment
// GOOD
if(!BAD)COUNTER++; // if the hand dealt is legal
// increment COUNTER
if(!fmod(COUNTER,10000))cerr<<COUNTER<<" "<<double(GOOD)/COUNTER<<"\n";
// print out the result every 10000 trials in the format:
// [ # of trials ] [ probability obtained so far to get full house ]
}}
Re: FULL HOUSE
Author: Greg Lawler
Date: Sun, 13 Sep 1992 19:21
Date: Sun, 13 Sep 1992 19:21
36 lines
1491 bytes
1491 bytes
In article <1992Sep13.143329.24796@wuecl.wustl.edu>, ppc1@cec1.wustl.edu (Peter Pui Tak Chiu) writes: > > hi everyone, > > 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. You're simulation is incorrect. In your program your are dealing from an infinite deck. (in particular, if the first card you deal is a king, then the probability the second card is a king is 1/13 instead of 3/51 as it should be). According to my calculations the probability of getting a full house from an infinite deck of cards is .00420.... This is the probability that you are simulating, (Infinite decks do not arise a lot, but sometimes at blackjack tables they deal from a large number of decks in order to beat card counters.) Greg Lawler
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads