Take a standard 52-card deck of playing cards, and shuffle it well, then
spread the cards in a row across a table. What is the probability that
seven of the face cards are in a group of ten in a row on the table? In
other words, what is the probability that of some ten consecutive cards,
seven or more are face cards?
Bob H
P.S. there are 12 face cards in the deck, and 40 cards that aren't face
cards.
--
-- Bob Harris =======================================================+
| To reply, carefully remove the plastic wrapper from my address |
+====================================================================+
> Take a standard 52-card deck of playing cards, and shuffle it well, then
> spread the cards in a row across a table. What is the probability that
> seven of the face cards are in a group of ten in a row on the table? In
> other words, what is the probability that of some ten consecutive cards,
> seven or more are face cards?
>
> Bob H
>
> P.S. there are 12 face cards in the deck, and 40 cards that aren't face
> cards.
Are you sure this isn't homework?
Anyway, I think it's
10
-----
\
> C(12,x) * C(40,10-x)
/
-----
x=7
--------------------------
C(52,10)
and Ed Murphy replied:
> Are you sure this isn't homework?
Well, even though I am back in school again, this isn't homework. It's
inspired by a human-genome problem the guy at the next desk was working on.
I thought I would simplify it to something more people could relate to and
with a much smaller data size. And I wasn't sure of the exact details of
his problem anyway.
> Anyway, I think it's
>
> 10
> -----
> \
> > C(12,x) * C(40,10-x)
> /
> -----
> x=7
>
> --------------------------
>
> C(52,10)
I think that's too low. That looks like the probability that the group
appears in the first ten cards. Or any other specific group of ten you
pick. But even if we fail in the first ten cards, we might have it in cards
2 thru 11, or 3 thru 12, or so on. So we have 43 different groups of ten
the pattern could occur at. And they aren't independent. In fact, if it
happens in one group, it seems pretty likely that it'll also happen in one
of the neighboring groups.
Bob H
I don't see any simple way to answer this. (Doesn't mean that there
isn't one.) I'm not going to take the time to write it now, but one
way to compute it in a tolerable amount of computer time would be to
use a nested iteration based on the positions of the first 6 face cards
in order as dealt. (Any group of 7 of the 12 face cards must include
at least one of the first 6.)
Number the positions from 1 to 52. Let the first 6 face cards in order
as dealt be in positions I, J, K, L, M, N. Then iterate:
for (I = 1 thru 41) {
compute probability of this value of I
for (J = I+1 thru 42) {
compute probability of this value of J
for (K = J+2 thru 43) {
compute probability of this value of K
for (L = K+3 thru 44) {
compute probability of this value of L
for (M = L+4 thru 45) {
compute probability of this value of M
for (N = M+5 thru 46) {
compute probabilities:
of this value of N
of 7 face cards in places I thru I+9
of 7 face cards in places J thru J+9 but not as above
of 7 face cards in places K thru K+9 but not as above
of 7 face cards in places L thru L+9 but not as above
of 7 face cards in places M thru M+9 but not as above
of 7 face cards in places N thru N+9 but not as above
compute overall probability
}}}}}}
The probability of a particular value of I, J, etc. (given the earlier
ones) is easy to compute, based on the number of combinations possible
for the later positions. For example, for I it's (52-I)C11 / 52C12.
Then for each of the known positions, you look at the 9 positions to
its right, to see which ones are known and how many more could be
face cards. In order for 7 face cards to be possible in positions K
to K+9, for example, if N = K+6 then all 3 of the next positions
must be face cards from the 6 remaining face cards, with probability
3C3*(43-K)C3/(46-K)C6. If N = K+5 then at least 3 out of the next 4
positions must be face cards, and so on, whereas if N > K+6 then the
probability is 0.
There is still some trickiness to avoid double-counting, but it looks
feasible to me.
However, maybe there is a better approach.
--
Mark Brader, Toronto | "Ask not for whom the compiler waits;
m...@vex.net | it waits for thee." -- Henry Spencer
My text in this article is in the public domain.
Bob Harris <plastic...@wrappermindspring.com> wrote in message news:<BD0CD1D5.40421%plastic...@wrappermindspring.com>...
>Howdy,
>
>Take a standard 52-card deck of playing cards, and shuffle it well, then
>spread the cards in a row across a table. What is the probability that
>seven of the face cards are in a group of ten in a row on the table? In
>other words, what is the probability that of some ten consecutive cards,
>seven or more are face cards?
>
>Bob H
>
>P.S. there are 12 face cards in the deck, and 40 cards that aren't face
>cards.
I hate to nitpick, but somehow this doesn't seem like a "puzzle."
Does anyone have an operation definition for what a "puzzle" is that
would explain why this doesn't feel like one to me?
I'm thinking that its non-puzzle-seemingness is related to that
quality of puzzles where the solver either thinks "This is
impossible," or actually finds himself wandering down a wrong path
before he finally gets the correct answer.
"How can Joe make the same number of cards face-up as face-down?"
seems impossible at first.
Monty Hall's dilemma leads one down a "wrong path" before he can
finally solve it.
However "What is 48934 x 2934? (and don't use a calculator!)" is just
a pain!
--
dga...@spamfreelinkline.com
and Dgates replied:
> I hate to nitpick, but somehow this doesn't seem like a "puzzle."
I would tend to agree. I think it's much more appropriate to
alt.math.recreational. However, over the past 5 years or so I have seen
many similar problems posted to rec.puzzles, which is why I posted to both.
Bob H
Exactly. What is it?
> This is college level combinatorics or probability, but when you've
> been away from school a few years you get lazy and the skills fade.
> It's 52 taken 10 at a time, looking for 7 of a group of twelve in one
> or more of those groups.
Yeah, and your answer is?
I think this recursive method will work:
Define bitson(x) as
= 0 if x == 0
= (x mod 2) + bitson (floor (x/2)) if x > 0
(handle as lookup table)
Define f(cardsleft, facesleft, lastten) as
= 1 if bitson(lastten) >= 7, else
= 0 if cardsleft < 0, else
= (facesleft / cardsleft) *
f(cardsleft-1, facesleft-1, (2*lastten+1) mod 1024) +
((cardsleft - facesleft) / cardsleft) *
f(cardsleft-1, facesleft, (2*lastten) mod 1024)
(cache calculated values)
The cache for f() should require 705536 entries, if I've calculated
correctly.
--
------------------------
Mark Jeffrey Tilford
til...@ugcs.caltech.edu
"Men, I wish I could be going on this mission with you, but the
admiral has asked me to remain aboard ship."
That stick must make sitting awfully uncomfortable.
Bob Harris <plastic...@wrappermindspring.com> wrote in message news:<BD0D61E6.4044B%plastic...@wrappermindspring.com>...
Should be
= 0 if cardsleft <= 0, else
(to avoid dividing by zero)
We also need
= 0 if facesleft <= 0, else
(cardsleft decreases at least as fast as facesleft, but we start with
cardsleft > facesleft)
> = (facesleft / cardsleft) *
> f(cardsleft-1, facesleft-1, (2*lastten+1) mod 1024) +
> ((cardsleft - facesleft) / cardsleft) *
> f(cardsleft-1, facesleft, (2*lastten) mod 1024)
> (cache calculated values)
>
> The cache for f() should require 705536 entries, if I've calculated
> correctly.
705536 = (52 + 1) * (12 + 1) * 2^10
But we consider only those triples with facesleft <= cardsleft, and there
are only
sum [cardsleft = 0 to 52, facesleft = 0 to min(12, cardsleft)] 2^10 = 611 *
2^10 = 625664
of these. Even this number is only an upper bound, since many of these
states will never be reached.
> --
> ------------------------
> Mark Jeffrey Tilford
> til...@ugcs.caltech.edu
This corrected recursion yields 348853 / 27657385, approximately 0.0126134,
which agrees with my Monte Carlo sanity check of 1 million trials.
Rob Pratt
"Mark J. Tilford" <til...@ugcs.caltech.edu> wrote in message news:<slrncegaaa....@ralph.earthlink.net>...
I don't think this is much easier to calculate. As someone has pointed
out, the groups of 10 overlap, so they're not independent; this makes the
problem much harder. (I saw the problem yesterday, without any replies,
and since I couldn't think of a nice way right off, I put it on hold.)
-- Christopher Heckman
I wonder if you would care to post the original problem? It sounds more
interesting than the playing-cards one. (I used to work with
human-genome stuff.)
Nick
--
Nick Wedd ni...@maproom.co.uk
and Nick Wedd replied:
> I wonder if you would care to post the original problem? It sounds more
> interesting than the playing-cards one. (I used to work with human-genome
> stuff.)
Sure. I'll ask him for more details tomorrow. The scale will be much
larger than the playing card one. I'm not sure whether the base set (the 52
playing cards in my version) was genes, nucleotide locations on a chromosome
or something in between. More than 52, for certain.
Bob H
If I thought and thought and thought I could *maybe* make a decent
fist of an exact answer. But I am at present disinclined to think so
much, especially when better brains than mine have already struggled.
Therefore, Monte Carlo or bust!:
1000000 spreads dealt, there were 7 face cards in a run of 10 in 11525
deals (1.15%)
--
Larry Lard
Replies to group please
and Rob Pratt replied:
> 705536 = (52 + 1) * (12 + 1) * 2^10
>
> But we consider only those triples with facesleft <= cardsleft, and there
> are only
>
> sum [cardsleft = 0 to 52, facesleft = 0 to min(12, cardsleft)] 2^10 = 611 *
> 2^10 = 625664
>
> of these. Even this number is only an upper bound, since many of these
> states will never be reached.
Am thinking that, since the recurrence never reaches back more than 1 card,
we could iterate forward on cardsleft (i.e. cardsleft=0 to 52). Only
12*1024 entries needed at each iteration, twice that in total.
> This corrected recursion yields 348853 / 27657385, approximately 0.0126134,
> which agrees with my Monte Carlo sanity check of 1 million trials.
I'm surprised the denominator in that small!
I was hoping to find something better than the strict recursion, though I'm
guessing no better method exists. When I scale this problem up to a deck of
a million cards looking for things bunching in a window of size a thousand,
memory limitations will kill this method.
Am guessing monte carlo will be my best choice for large scale problem.
> Define bitson(x) as
> = 0 if x == 0
> = (x mod 2) + bitson (floor (x/2)) if x > 0
By the way, is that in some actual computer language or is that simply a
convenient notation on your part? I'm using mathematica to evaluate things
like this, but I find it's language is not as straightforward as I'd like.
Thanks,
Bob H
Just convenient notation.
Below is the Mathematica code I used. It is nearly identical to the
pseudocode Mark posted. The call to f[52,12,0] took about 30 seconds.
bitson[0] = 0;
bitson[x_] := bitson[x] = Mod[x,2] + bitson[Floor[x/2]];
f[cardsleft_, facesleft_, lastten_] := f[cardsleft, facesleft, lastten] =
Which[
bitson[lastten] >= 7,
1,
facesleft <= 0,
0,
cardsleft <= 0,
0,
True,
(facesleft / cardsleft) * f[cardsleft-1, facesleft-1, Mod[(2*lastten+1),
1024]] +
((cardsleft - facesleft) / cardsleft) * f[cardsleft-1, facesleft,
Mod[(2*lastten), 1024]]
];
Rob Pratt
I tried Monte Carlo too, doing three runs of a million shuffles. The
results:
12436
12453
12446
I am using the standard Perl random generator, which should be all
right for experiments this size. However, our results don't match.
It is extremely likely that at least one of us is doing it wrong.
My 20 lines of Perl are here: http://www.alesia.dk/jens/ten-52.pl
In Jens's program, I changed the for-reverse-push-splice-rand loop to use
the random number generator differently, which would tend to avoid any
bias due to errors in it. (This version also happens to be a bit faster,
although its time is theoretically unbounded.)
@c = ("-") x 52;
for ($i = 0; $i < 12; ++$i) {
for(;;) {
$r = int(rand(52));
next if ($c[$r] eq "F");
$c[$r] = "F";
last;
}
}
$cc = join('', @c);
The other part of Jens's code seems correct to me, and my results on 3 runs
of 1,000,000 trials each were similar to his:
There were 12654 hits
There were 12310 hits
There were 12607 hits
--
Mark Brader, Toronto | "The singular of 'data' is not 'anecdote.'"
m...@vex.net | -- Jeff Goldberg
How very diplomatic of you =)
I went back and recoded my simulation using more problem-specific
code, rather than my already-existing general card simulation engine
which I had used before. This new code gave these numbers on three
runs of a million:
12479
12515
12429
which look much more like your numbers (and the analytically dervied
solution). So I went back and re-examined the code of the
generic-engine version. The 'check' part was fine, tested by
substituting in the 'check' code from the other version. So the finger
of suspicion moved to the 'fill' part. Perhaps someone could take a
look at this VB code and suggest whether I am doing something wrong,
or if I have somehow discovered a bias in the RNG:
Generic card engine does this:
Shuffle routine simply resets a 52-member boolean array
DealCard returns an as-yet-undealt card thus:
Public Function DealCard() As Integer
Dim i As Integer
Do
i = Int(Rnd() * 52)
Loop Until Not bDealt(i)
bDealt(i) = True
DealCard = i
End Function
[Rnd() is supposed to return a uniformly-distributed random variate
between 0 and 1-epsilon, inclusive]
To obtain a complete deal I do this:
Shuffle
For i = 1 To 52
spread(i) = DealCard()
Next i
I then proceed to examine spread() for runs of 7 face cards in 10
consecutive cards - as I mentioned, this code is correct.
The problem-specific code, on the other hand, also uses a 52-member
array, but this time it is initially filled with 0s then 12 1s are
inserted thus:
For i = 1 To 12
Do
p = Int(Rnd() * 52) + 1
Loop Until arr(p) = 0
arr(p) = 1
Next i
---------------------------
If I have not made a startling error which I haven't found, and Rnd()
is doing what it's supposed to, then both these methods should give a
list of 52 items, containing 12 YES items and 40 NO items, randomly
distributed. Right? Yet the former method consistently gives only
~11500 hits per million, while the latter give ~12400 - the correct
value.
If this *is* highlighting some bias in Rnd(), how would I a) make a
more minimal example, for demonstration purposes; and b) work around
this bias so I can again trust my generic card engine simulator?
This should probably be a new thread, maybe with a crosspost to a VB
group, but I will see what I get here first :)
I got several different answers by simulation, also. For expample, I
got 12467 hits, where the simulation counted only cases where exactly
7 face cards were found, counint only the first set of ten cards. When
more than one set of ten cards were counted, there were 21202
hits(1,000,000 trials). When the rules were set to 7 or more, I got
12741 for the first hit, and 22567 counting all hits.
This did, however, introduce another interesting question, i.e., how
many different ways are there to distribute the 12 face cards to
permit two, three, etc. sets of 10 to have either exactly 7 or 7 or
more faces cards. Similarly, what is the maximum number of sets of ten
cards that contain at least 7 face cards?
Earl
Here is an easier, related, puzzle involving no statistics.
Take the same deck and arrange the cards in a row as you choose. Score
a point for each group of ten in a row that has at least seven face
cards. What is the most you can score?
I have no specific knowledge of VB, but it seems to me that DealCard
is returning an integer between 0 and 51, which is then used to place
a value in spread, which is indexed from 1 to 52.
This might be exactly as intended. But if your checking code then
assumes values from 1 to 52, not values from 0 to 51, you would have
an off-by-one error, which might account for your abnormal results.
If I have some time later, I will try to verify this hypothesis by
changing my own code to use 11 face cards instead of 12 and see what I
get.
You use the RNG in a way that is unlikely to get it into a rut that
would produce a bias, and you can demonstrate that you get what looks
like the right answer by using the RNG differently, so my bet is that
the bug is in the use of the RNG, not in subtle biases of the RNG.
I tired running with 11 face cards, to see if that might explain it,
but that gives much lower numbers. Exit that hypothesis.
The answer seems obvious: 18. Is it also right?
Bob H
Do you mean 9? That's all I can see, although it uses 18 cards (12 face
cards and 6 non-face), so I'm wondering if you've just misunderstood the
scoring. Or I've got totally the wrong approach...
Regards,
Mike.
Ah, you're right. 9 would be the score for that pattern I had in mind.
Bob H
By the way, even though the groups aren't independent, the expected number
of groups of ten consecutive cards containing at least 7 face cards is 43
times Ed's sum above. Explicitly, Ed's sum, which can also be expressed as
sum [k = 7 to 10] binom(10,k) binom(42,12-k) / binom(52,12),
is 28741 / 55314770, approximately 0.00051959.
The expected number of "face-rich" groups is therefore 43 * 28741 / 55314770
= 28741 / 1286390, approximately 0.0223424.
Rob Pratt
and Nick Wedd replied:
> I wonder if you would care to post the original problem? It sounds more
> interesting than the playing-cards one. (I used to work with
> human-genome stuff.)
I discussed this with him today. The problem amounts to a deck of about
11,000 cards, with about 1,000 aces, looking at windows of about 100 cards
and calculating how surprising it is if there's a window that has 25 or more
aces.
As to the biological significance of it, I'm a little fuzzy on the details
(I'm pretty new to the field, and my biology is still extremely lacking).
The 11,000 cards is a set of genes. This is about half the human genes, and
I think it's the set of genes that have been annotated. The 1,000 aces is a
subset of those genes that have some specific property, possibly relating to
ontology (a word that I know nothing more of than how to spell).
I'm not clear at all on what the windows represent. I'm certain that he's
*not* looking at consecutive windows in sequential order, so my analogy is
not really appropriate. However, I'm also sure he's not just choosing 100
genes at random. They are 100 genes that have some property that's
allegedly unrelated to the ace property.
Bob H
Then can we not say:
Choosing 100 genes at random we expect about one eleventh of them (ie 9 or so)
to have the property.
If 25 have the property you have almost certainly selected for the property.
But while I don't know how to calculate that certainty (being allergic to
stats), I believe that this is just stats 101, sampling populations.
--
Patrick Hamlyn posting from Perth, Western Australia
Windsurfing capital of the Southern Hemisphere
Moderator: polyforms group (polyforms...@egroups.com)
Interesting. There used to be over 100,000 human genes.
Various companies have claims over various sets of genes - patents,
sequences, antibodies, detection mechanisms. They all want to be able
to report as high a coverage of the genome as they can. So it is in the
interests of all these competing companies to talk the total number
down. With them all acting in the same direction, it seems they have
succeeded.
It's impressive what science^W the market economy can achieve, when
everyone acts together.
>I think it's the set of genes that have been annotated. The 1,000 aces is a
>subset of those genes that have some specific property, possibly relating to
>ontology (a word that I know nothing more of than how to spell).
>
>I'm not clear at all on what the windows represent. I'm certain that he's
>*not* looking at consecutive windows in sequential order, so my analogy is
>not really appropriate. However, I'm also sure he's not just choosing 100
>genes at random. They are 100 genes that have some property that's
>allegedly unrelated to the ace property.
>
>Bob H
>
Nick
--
Nick Wedd ni...@maproom.co.uk
--
Odysseus
and Odysseus replied:
> Shouldn't that be "ontogeny", perhaps? IIANM "ontology" is the branch
> of metaphysics that addresses the question of existence, while
> "ontogeny" is the development of an embryo or seed into an organism
> of a certain kind -- as in Haeckel's dictum that "ontogeny
> recapitulates phylogeny".
Looks like I knew even less about the word than I thought!
Bob H
Actually 'gene ontology' is a commonly used term in genetics. I snipped this
from a page I found with Google:
====================
Using the Gene Ontology (GO)
What is GO?
For each of three categories of biological information - molecular function,
biological process, and cellular component - a set of terms has been selected
and organized. Each set of terms uses a controlled vocabulary, and parent-child
relationships between terms are defined. This combination of a controlled
vocabulary with defined relationships between items is referred to as an
ontology.
====================
> What is GO?
> For each of three categories of biological information - molecular function,
> biological process, and cellular component - a set of terms has been selected
> and organized. Each set of terms uses a controlled vocabulary, and parent-child
> relationships between terms are defined. This combination of a controlled
> vocabulary with defined relationships between items is referred to as an
> ontology.
> ====================
good thing there was a lot of context with this line,
as i cant imagine what head scratching it might have
engendered if it had posted in a snipped fashion, like
i did above, in alt.math.recreational, to say nothing
of rec.games.abstract.
;-)
- nate
--
Odysseus