Basic Probability

Let’s say specifically the probability that some card matches in exactly one run through of the deck. Now, without loss of generality we can let one deck be sorted (reorder one deck and perform the same permutation on the other deck). The question has become "how many permutations of 52 items have no fixed points.

How many permutations of n items have p fixed points? Denote this by F(n,p). Now, we can see how many permutations have p fixed points by picking p points to be fixed ([sub]n[/sub]C[sub]p[/sub] choices) and permuting the rest with no fixed points (F(n-p,0) choices). Thus

F(n,p) = n!/p!(n-p)! F(n-p,0)

For p=0, this gives F(n,0) = F(n,0). How can we get p=0 to recurse? By noticing that

n! = F(n,0) + Sum[sub]p=1[/sub][sup]n[/sup] n!/p!(n-p)! F(n-p,0)

F(n,0) = n!(1 - Sum[sub]p=1[/sub][sup]n[/sup] F(n-p,0)/p!(n-p)!)

Now, we should define F(0,0) as 1 (since, if nothing else, F(0,0) = F(n-n,0) = F(n,n))

F(1,0) = 1(1 - F(0,0)) = 0
F(2,0) = 2(1 - F(1,0) - F(0,0)/2) = 2 - 0 - 1 = 1
F(3,0) = 6(1 - F(2,0)/2 - F(1,0)/2 - F(0,0)/6) = 6 - 3 - 0 - 1 = 2

The probability of no matches ever is F(n,0)/n!, so the probability of at least one match is

1 - F(n,0)/n! = Sum[sub]p=1[/sub][sup]n[/sup] F(n-p,0)/p!(n-p)!

Anyone care to code this up and see what F(52,0) is?

Yeah, anytime you see e with no explanation, that’s what it is.

I’ll take a look at it later tonight.

I’d have done it, but since upgrading to OS 10.3 I need to put in the department’s license code for Mathematica again…

So if someone got 33/52 (low) to 37/52 correct, they might be clairvoyant?

OK, I took a quick look at it. I don’t have a library for arbitrary integer arithmetic, so I don’t think I’ll be able to do this.

That would really depend on the number of trials you perform. Due to the nature of statistics, things which we consider improbably DO happen, but they tend not to repeat themselves.

If we take pasta’s simulation (guessing using information from the previous cards and optimium strategy) and assume it to be true, the bar is no longer at 26 cards, it’s at 29. I’d say that if you performed 100 trials and your average number of correct guesses was 35 or above (there are some other statistics you’d need to perform using standard deviations and the like to show that your guesses weren’t just wildly all over the map, for instance), then there would be something for the scientific community to be interested in.

If there’s a mistake in the simulation, none of the above applies. Except the first paragraph.

Never mind, I figured out how to get around that.

I’m not schooled in probability, but if someone got 40/52, only one time, I would think this should be of high interest! What are the odds?

I don’t have the tools at work to give you exact numbers, but hitting 33 out of 52 really isn’t unusual. It’s well within random chance. Actually, if you’re doing a whole deck, you damn well SHOULD get more than 26, since you should be able to count the number of reds or blacks that have come up and therefore guess with greater than 50% accuracy towards the end of the deck. 33 isn’t impressive at all.

When I’m alone and bored in an airport or something, I play a game where I pull out a coin and flip it 162 times (the number of games a baseball team plays in a season) and see what my “Record” is. The likeliest result is 81 heads, 81 tails, but you would be quite amazed at how often I end up with something like 95 tails and 67 heads, or 90 heads, 72 tails.

Now if you could average about 37 hits per 52 cards out of a genuinely random deck (say, 52 cards shuffled out of an eight-deck shoe) that would be impressive, and you should give the Randi people a call and try out for the $1,000,000 prize.

Repeatability is the key here.

If you flip a (fair) coin ten times, you’re just as likely to get HHHHHHHHHH as HTTHHHHTHT, but if you could consistently get either pattern (or just “know” which pattern you were going to get), you would be able to repeat your experiment.



double Pascal[53][53] = {0};
double factorial[53] = {1};
double F[53] = {0};

int main()
{
	Pascal[0][0] = 1;
	F[0] = 1;

	for ( int i = 1; i < 53; ++i )
	{
		Pascal*[0] = 1;
		for ( int j = 1; j < i + 1; ++j )
		{
			Pascal*[j] = Pascal[i - 1][j] + Pascal[i - 1][j - 1];
		}
	}

	for ( i = 1; i < 53; ++i )
		factorial* = i * factorial[i - 1];

	for ( i = 1; i < 53; ++i )
	{
		for ( int j = 1; j < i + 1; ++j )
		{
			F* += F[i - j] * Pascal*[j];
		}
		F* = factorial* - factorial* * F*;
	}

	for ( i = 0; i < 53; ++i )
	{
		printf( "%f
", F* );
	}

	return 0;
}


This doesn’t work, even though it looks like it should. Perhaps someone can use this as a starting point.

I thought more here that someone could count cards with one deck …

Uhh…what? I don’t understand what you mean here…

I think I know a strategy that will win 100% of the time:
Start with a count of 0. Every time a red card shows up, increment the count. Every time a black card comes up, decrement the count. When there is one card left, stop the dealer, and say “red” if the count is -1 and “black” if the count is +1. This presumes that you’re dealing from a standard deck, of course.

You can’t. You HAVE to say red. Read the rules again.

I just put way to much work into this, but let me try to explain what I think it is.
I am assuming perfect card counting.

Imagine a deck of only two cards. The first one you guess on 50/50 the second one you know so it’s 100. half the time you get 50 percent right, half the time you get 100 percent right, so explectation is 75% correct.
Look at a deck of four cards



the possibilities for the stacking of the deck are

B      B       B     R     R      R
B      R       R     B     B      R
R      B       R     B     R      B
R      R       B     R     B      B


1st card 50/50
2nd card you always have a 2/3 chance of guessing it correctly
3rd card one third of the time you know it(only color left) 2/3 thirds of the time you are 50/50( 1/31/1+2/31/2= (1/3+2/6)=(1/3+1/3)=2/3
4th card 100%
so average is (1/2 + 2/3 +2/3 +1)= (17/6) 2+5/16 right.
and aveagre expectation per card in (1/2 + 2/3 +2/3 +1)/4 = (17/6)/4=17/24
I also did it for a six card deck(really freaking ugly so I won’t repeat the whole thing but I came up with

1st card 1/2
2nd card 3/5
3rd card 3/5
4th card 7/10
5th card 7/10
6th card 1/1
so number right is (1/2+3/5+3/5+7/10+7/10+1) (5/10+6/10+6/10+7/10+7/10 +10/10)=(41/10)= 4+1/10
average expectation of being right be card is (41/10)/6=41/60
looking at the expectation to be right per card

2 card deck: 3/4 75%
4 card deck 17/24 70.83%
6 card deck 41/60 68.33%

I was two lazy to go more cards then six since I was doing it by hand. But,
It pretty much fits with my theory. You will always be 100% on the last card, and there are cases, where through counting, you will have a betterchance of guessing the next card) But as there are more cards, these favorable chances become less common. All in it you over timewill have slightly over 50% probability for the average card. It’s going to be a function curve approching 50% as N approaches infinity where N is an even number of cards in the deck. So as you get more cards in the deck you will get ‘slightly’ over half with slightly becoming smaller and smaller as more cards are added.

So pasta’s 28.86 sounds about right.

:smack:

There’s no need for any code to do this. We know that the probability of at least one match is 1 - F(n,0)/n!, and that the probability of at least one match is 1 - D[sub]n[/sub]/n!. Set 'em equal, simplify, and you get that F(n, 0) = D[sub]n[/sub]. It’s good that they’re equal, cause those are both ways of denoting the number of derangements on n objects.

You can get these numbers straight from the above distribution:

exactly 40/52 in one shot: P = 0.000108 +/- 0.000009
exactly 33/52 in one shot: P = 0.0340 +/- 0.0002
At least as good as 40/52 in one shot: P = 0.00014 +/- 0.00001
At least as good as 33/52 in one shot: P = 0.0703 +/- 0.0002

Nice! Can you do these again with card counting, i.e. if the remaining deck is +1 populated or more black, go with black and vv with red?