Recall the first article when I talked about a question, a world and initial conditions, and so?
Well, most of the times the questions you ask are complex in nature. This means, if I played a theoretical single-card poker game (lets expand the Kuhn Poker Game to use the full range of 2..A cards) and my question was just:
What is the probability of me getting K?
Without so much thinking, the answer is 1 in 13. The easing fact here is that the answer does not depend on the value: Asking regarding the K is the same as asking regarding A, 2, or 3.
This is because the qusetion does not involve numeric ordering (I mean comparison! don't confuse the ordering word here with the shuffling we discussed earlier). There are many times when the question involves ordering and the analysis goes even deeper!
Remember when I said that probabilities calculations is a quick fact of adding all the true cases (for your expected condition) and test it against the whole cases... but that you'd never enumerate the true or whole cases one-by-one? Well: although you will rarely do this, you could easily get into more fine-grained analysis which would require you to count or add different scenarios.
So, again, the question (which involves an experiment, which in turn involves the definition of initial states), may in fact be broken in sub-questions and sub-experiments, and so more elaborated analysis appears here.
1. Complementary question.
Lets keep this for reference only, since we will use it later.
A complementary question is when you invert the condition. An example is:
What is my chance of not getting K?
The answer, disregarding the asked value, will be 12/13
.
Formally speaking, if our probabilistic proposition is p(X)
, the complementary will be written as ~p(X)
or p(~X)
(not the exact same concept wording, but indeed the same return value), where X is the proposition.
Notice how I use proposition variables in uppercase. Usually in logic, proposition instance variables are noted in lowercase letters while proposition template variables in reasonings are uppercase. Here I use always uppercase for instances, since those propositions are always templates, while lowercase variables are meant to actual, e.g., numeric variables, like X
the template and card = K
the proposition.
The values of ~p(x)
is, if you did not guess, 1 - p(x)
(100% instead of 1, if you are expressing in percent terms).
When speaking about discrete probabilistic sets, we make three sets:
- Overall cases: {2 3 ... J Q K A}
- Expected cases: {K}
- Complementary cases: {2 3 ... J Q A}
And the probability in this case will become #Expected/#Overall
.
2. Independence of experiments.
Let's say you execute the experiment of your question, and you obtain the result. We can conceive two types of experiments to this extent:
- Experiments that, when executed, alter the world
for successive experiments.
- Experiments that, when executed, make no difference on further experiments: such further experiments will behave like if no former experiment was executed.
Example:
Imagine we have a 6-faced die. A regular craps die. We roll it once. What is the chance of getting 6?
- World: our die. The die is a not-charged 6-sided die. We could think that getting a number is equally easy no matter what number is. The die is so perfect that it will not gradually physically deform after each launch. It is an ideal, materially strong die.
- Initial state: we rolled it and got a single value.
- Condition: such value must be 6.
Our probability would be 1 in 6, or 1/6
.
This is practically an axiom: if all the N
possible finite and discrete values are though to be equally easy, each value has 1/N
probabilities of arising.
However we clarified (most of the times it is not needed to clarify like this) that rolling the die does not deform it for future rolls. When we throw it again, our chances will be 1/6
of guessing the number.
It is said that both experiments are independent, since the former does not affect the outcome of the latter. Saying this, if you want to calculate a compound probability, you will:
Use the AND operator:
What is the probability of getting 6 in the first roll and 6 in the second roll? (actually you could pick any two 1..6 numbers, perhaps different, to make this question).
You will compose both probabilities by saying:
- If I hit 1/6 in the first die, I continue. Otherwise, the case failed.
- If I hit 1/6 in the second die, I mark it as expected. Otherwise, again, the case failed.
- Summary: I will only accept 66 case as good, among other XY cases.
You have now a probability of 1/6
of having 6 in the second roll but you have to pass a former 1/6 probability to reach this instance. So the probability of winning is 1/6 of 1/6, or 1/6 * 1/6
.
We can say that, if we have this cartesian product of the possible initial states (which are the two rolls), we have:
11 12 13 14 15 16
21 22 23 24 25 26
31 32 33 34 35 36
41 42 43 44 45 46
51 52 53 54 55 56
61 62 63 64 65 66
We only care about the intersection of those variables in that space. The second variable will accept:
16
26
36
46
56
66
While the first will accept cases:
61 62 63 64 65 66
And the compound probability will only accept the intersection, which is:
66
Summary The probability p(x & y)
is calculated as p(x)*p(y)
.
Use the NOT operator:
What is the probability of NOT getting 6 in my roll?
You already know what is the probability of 6 (or any specific number): 1/6
. Let's calculate the complementary!: 1 - 1/6 = 5/6
.
With this tool you can calculate certain complex questions, like:
I am getting a club-suited card, and a heart-suited card. They are being dealt to me from different single-suit decks. What is the probability for the former being A and the latter not being K?
Lets go by parts.
- Probability of getting A club:
1/13
.
- Probability of getting K hearts:
1/13
(the same value).
- Probability of NOT getting K hearts:
12/13
(the complementary).
- Probability of getting Ac AND NOT Kh:
1/13*12/13 = 12/169
.
It is an exercise to you to express it in terms of intersection in the cartesian product.
Use the OR operator:
Comparing to sets, if AND was an intersection of cartesian produce and NOT was the complement, then the common sense would tell us that OR is the union. The question could become:
What is the probability of getting 6 in either die (perhaps both dice)?
The cardinality of A U B
(let me write it A | B from now) is always #(A | B) = #A + #B - #(A & B)
. We can calculate it in that way, saying:
- Cases for first 6: 6.
- Cases for second 6: 6.
- Cases for both 6: 1.
- Cases for either 6: 6 + 6 - 1.
The accepted subset of the cartesian product will show:
16
26
36
46
56
16 26 36 46 56 66
(11 elements).
The intersection's cardinality is subtracted because its elements appear twice (once in A, once in B), and we must not count elements twice,
so we subtract the intersection... once.
Another way of calculating it, when it becomes too complex (e.g. A | B | C | D
would be a nightmare involving 15 terms) is to fall back to De Morgan's Law:
p(A | B | C | D) = ~p(~A & ~B & ~C & ~D)
This is: The union is the complement of the intersection of the complements of every involved set. This is true for sets identity, cardinality, simple propositions, and yes: probabilities.
Our simplest union case is when the events are disjoint. This means: the intersection of such events is empty. Example:
Probabilities of having hole cards AA or having hole cards KK.
The approach is simple here: p(AA | KK) = p(AA) + p(KK)
. Following this example, the probs of getting a specific pair in hole cards is 1/221
, but the following of getting any pair in hole cards is adding from p(22)
to p(AA)
. Those 13 terms are the same (since amount of cards in the deck is the same for each number), so you just say that getting a specific pair XX has 1/221
probabilities, and having any pair has 13/221
, or by fraction simplification: 1/17
.
3. Non-independent or world-sharing probabilities.
These scenarios can be tagged (in a non-exclusive way) in:
- Probabilities of events belonging to experiments which have a non-independent execution. Examples: probabilities of my cards being AA, and probabilities of my opponent's cards being KK.
- Probabilities of multiple events belonging to a single experiment. Example: probabilities of my cards being suited, and probabilities of my cards being greater than 10.
The first scenario, in poker, is strongly related to the permutation concept we studied earlier: one experiment produces a side effect (that's what we call in software development when a procedure we execute, usually a function, aside from returning a value it alters the world it executed into) and the next experiment is affected by such side effect.
If we take two cards for you and analyze, and then two cards for an opponent and analyze, and want to combine those experiments by the AND operator, like the AA and KK question, we proceed like this:
- The first experiment will involve taking 2 out of 52 cards.
- The initial state will involve those two cards taken from 52.
- The expected condition is when cards are AA. The odds for that are
1/221
.
And then ...
- The second experiment will involve taking 2 out of 50 cards. Reason?: The first experiment produced a side effect on my world now: I have a less-sized deck to draw from.
- The initial state will involve those two cards taken from 50.
- The expected condition is when cards are KK. The odds for that are not
1/221
anymore but 6/50c2
or 1 in 205 hands.
Finally we combine them:
Me AA, him KK
p(me AA & him KK) = p(me AA) * p(him KK given cards were dealt to me) = 1/221 * 6/1225
Why is this closely related to permutations? Because permutations of R from N can be thought as R inter-dependent experiments involved dealing elements from a finite set (e.g. dealing cards), whose results are concatenated in a sequence in the end. To this extent, the probabilities of getting one specific card is 1/52
, while for getting two specific cards is 1/52 * 1/51 = 1 / 52p2
.
This way of conditioning assuming uniform poker decks is just a specialized case of conditional probabilities. Conditional Probabilities is useful when the events are even less independent and, depending on the asked question, this can occur even with uniform decks. An example:
What is the probabilities of getting 3?
1/13
What is the probabilities of getting 3 GIVEN I ALREADY DREW A SINGLE CARD BEFORE AND WAS ALSO A 3?
3/51 or 1/17
What is the probabilities of getting 3 GIVEN I ALREADY DREW A SINGLE CARD BEFORE AND WAS NOT A 3?
4/51
So... what's the overall probability of getting a 3 in my second draw?
This time we broke down on different scenarios since they were different in nature for this question. Is not as if we multiplied by 13 in the former examples, since this time the example scenarios produce different outcomes. This is better explained in this Bayes Law article, which I would like to summarize:
- The first experiment we care about produced many disjoint scenarios. In this case, let me call them IS3 and NOT3. The sum of probabilities of all the possible scenarios will be 1.
- The second experiment we care about produced a result which depended on the result of the first experiment. So the chance of success of a second-card = 3 is:
p(second is 3) = p(first is 3) * p(second is 3 given first was 3) + p(first is not 3) * p(second is 3 given first was not 3)
- Read the article regarding bayes since you will have, perhaps, a deep tree or matrix to analyze! depending on your needs.
Please note: everything we talked regarding union, intersection, and complement also applies in these cases. The difference is how the whole initial cases are enumerated, but the rules for those operators still apply.
There is, however, an exception: There is no formula for intersection, because intersection is just a fact here, part of the world to analyze.
The other flag for our experiment is analyzing the possible scenarios. Depending on the nature of the question, our experiment may group their possible outcomes in different sets or scenarios. Take an example:
What card type will I draw?
- High cards: J Q K A of each suit.
- Middle cards: 8 9 T of each suit.
- Low cards: 2 3 4 5 6 7 of each suit.
In this case the scenarios are totally disjoint, and so those adding back give the whole set (i.e. a probability of 1 in the union).
But let's check this question, which is indeed an interesting poker question many of us asked maaaany times:
The table is Q♣ K♥ 5♣ 8♠
My hand: T♣ J♣
Two draws are present here (flush draw, and straigh draw). What is the probability of completing my draw in the river?
So let's enumerate the scenarios!
- To complete flush: A K 9 7 6 5 4 3 2 of clubs (9 elements).
- To complete straight: A 9 clubs A 9 diamongs A 9 hearts A 9 spades (8 elements).
- To complete simultaneous: A 9 clubs (2 elements).
- To complete either: A K 9 7 6 5 4 3 2 of clubs A 9 diamongs A 9 hearts A 9 spades (15 elements).
In this case it was easy to me to enumerate the cards on each set, but the underlying concept is still valid here:
- Flush has a probability of
9/46
, where 46 cards is the amount of cards you did not see now.
- Straight has a probability of
8/46
.
- We could be tempted to say that the probability either event is the sum, but we would be wrong since those sets have a non-empty intersection (i.e. cards that belong to each, although in practice those cards would make the flush since it is better than the straight). If we add the events cases in a naive way, the cards A♣ and 9♣ would be added twice, so we must subtract such intersection, to have those cards only once in the final set.
Finally, 15/46
is the always told almost one third.
As you noticed, the union, intersection, and complementary operators work here as well although the elements in the set are a bit different.
Remember the examples in the former article when my hole and flop spaces were combinatorial? This is because I took a shortcut on using these points: both the bayesian conditioning (for multiple scenarios) and the non-independent experiments (when I said my whole possible cases were 52c2
and 50c3
for both sub-experiments respectively).
4. Value-dependent probabilities.
This one is the final point I think we should address, since many questions come like this:
What is the chance that I get a specific hole-cards pair XX, and my opponent gets a hole-cards pair, AND I WIN? (disregarding community cards)
Remember the question of two hole pairs where the probability of that happening was 1/221 * 6/1225
? Well, that answer and that analysis is the probability of pair-vs-pair with specific values. We need a different approach now since the pairs have different conditions now: Mine must WIN. So now, the pair I am asking for, or testing for, matters. We must count multiple scenarios or predict a pattern for this. Lets do it:
- AA vs KK is a good case, with probability
1/221 * 6/1225
.
- AA vs ... 22 (11 scenarios here, same probability each scenario, as before).
- KK vs QQ and 11 other scenarios, each with probability as before.
- ...
- 33 vs 22. Same probability.
There is a simple way to sum the cases. My tip is the following:
- Create a mapping function. In Python I declared this one:
m = lambda c: '23456789TJQKA'.index(c)
. Consider the value cardinality = 13 (amount of possible values or ranks).
- Apply the mapping function to X (XX is your pair). You will get 0 to 12.
Back on the question: What is the chance of me getting XX and him getting YY and I win? also writable as:
What is the chance of me getting XX and him getting YY and -strictly- X > Y?
So the chance of we getting specific-vs-specific did not change: 1/221 * 6/1225
. But the cases I ask groups a set of cases: my pair is specific, but the other one is any pair I can beat.
What pairs I can beat with my specific XX? I can beat m(X)
pairs, since m(A) = 12
and beats 12 pairs, tying with another AA, while m(2) = 0
and beats 0 pairs, tying with another 22.
The final calculation here is:
- Possible dealt hands:
52c2 * 50c2
.
- Expected cases of my specific XX beating his YY:
4c2 (suits for my pair) * m(X) (amount of values I can beat) * 4c2 (suits for those pairs)
.
- Also writable as:
4c2/52c2 (experiment XX) * m(X)*4c2/50c2 (instances of experiment YY I would beat)
.
5. Summary
So remember:
- It is important to distinguish different scenarios you care about when they are different outcomes in the same experiment. Specially important to distinguish whether they are, or not, disjoint.
- It is important to distinguish whether two or more experiments (either different or instances of the same procedure) have side-effects affecting the execution and conditions over the next experiment, or they are totally independent.
- It is important to distinguish whether to compare card values or not. The former will require the mapping function, while the latter will not.
- If your question is about the probability of certain hand layouts involving values X and Y (and perhaps more variables), what I suggest is to freeze X and Y in example values and calculate a function for them. Only then you should check whether values X and Y also satisfy a condition in the question.