Solving the math behind the 39.94% chance calculation.

Challenges and Articles forum

Posted on June 21, 2015, 2:41 p.m. by -Logician

Disclaimer -- I know some of you might be completely and absolutely baffled that there are actually people that exist who are interested in this, and that's understandable. Please respect the few of us who do, and refrain of posting comments like, "Who even cares?" This thread is purely in the interest of probabilities in a specific setting. Please be respectful.

This is a personal challenge I gave to myself to figure out how in the hell someone calculated that there's a 39.94% chance that you'll draw at least one of four copies of a given card in a 60 card deck in your opening hand. It seems arbitrary at first, but once you try to really figure it out, you hit some boundaries.

The first boundary probably being that 60! is 8.32e81. An 82 digit number... That's not exactly very easy to work with, and it's probably part of the overall equation. (spoiler alert: it is)

For those of you who may not know what the exclamation mark means, or maybe you forgot, it means "factorial." For example, 5! is Five Factorial, which means 5 * 4 * 3 * 2 * 1, which if you do the math, is 120. One more example, 12! is Twelve Factorial, which means 12 * 11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 (you don't really have to multiply by 1, obviously, but yeah). And if you do the math on that one, it's 479,001,600. You can see that factorials rise exponentially, and can easily produce some huge numbers.

Well anyway, screw boundaries. Let's dive right into the juicy stuff! I've already figured this problem out, and I'll try to backtrack my thinking process as well as I can.

Let's start by defining some key variables in this equation, and to make this easier to explain, let's just say that the card we're focusing on is Farseek (Oh, how I loved that standard season).

  • n = the number of cards in your opening hand. (in this case: 7)
  • y = the number of cards in your deck. (in this case: 60)
  • x = the number of copies of the card we're focusing on in the deck. (in this case: 4 Farseeks)

In this problem, it doesn't matter what the other cards are in the deck, only that there are (y - x) of them, which in this case is 56. There are 56 cards in the deck that are not Farseek.

To discover the chances of drawing at least one Farseek in your opening hand, I need to figure out how many possible ways the four copies of Farseek can possibly be arranged within the deck. Then I must discover, after removing n cards from the deck (in this case: 7, leaving 53 cards remaining), how many arrangements of x Farseeks there can be in just those 53 cards. What that does is discover how many deck states there are where Farseek is not in your opening hand. Logically speaking, if I know how many ways x Farseeks can be arranged in the deck, and subtract the number of arrangements that x Farseeks can be arranged in a deck that doesn't include my opening hand (the other 53 cards), then I'm left with the number of arrangements that has at least one Farseek in my opening hand.

Essentially I can represent that with (A - B) / A, where A is the number of arrangements x Farseeks can be placed in a deck of size y, and B is the number of arrangements where x Farseeks can be placed in a deck of size (y - n).

Great, so how many arrangements are there? Right. This is where it gets a little bit more complicated. The most complicated thing probably being that in any given arrangement, you can take any two Farseeks and just switch their positions with one another in the deck, and technically, that's a different arrangement even though it looks like the same one. Since in this deck there are four Farseeks, that means that in any given arrangement of Farseeks in the deck, there are 4! ways to rearrange the Farseeks and get what would appear to be the same result. Just to be clear, I'll give a simple example. Let's say we have the extraordinary arrangement where the top four cards of the deck are all Farseek. In actuality, there are 24 arrangements where the top four cards are all Farseek, because you can just reorder those four cards in 24 different ways (because 4! is 24). This must be taken into consideration.

Let's scale this down to just a 5 card deck with 4 Farseeks. Let's not think about drawing a hand, just look at this as an example. In this case, there's only one card in the deck that is not Farseek. It's pretty clear that the one card that isn't Farseek can be in any one of five possible positions. So in this case, while there are 5! ways that these cards can be arranged (120 possibilities), there are only 5 distinct ones, and I'll list them right now.

  • The one where the card that isn't Farseek is on the top.
  • The one where the card that isn't Farseek is second from the top.
  • And then third from the top.
  • And then second from the bottom.
  • And then on the very bottom.

Yes, the Farseeks can be arranged in 4! different ways, but just by looking at the deck spread out, we would only see these five DISTINCT arrangements. So what is the relationship between 5! and 5? Well, the answer is actually 4!. It just so happens that (5! / 4!) = 5. Do the math and see for yourself. So is it that simple? Almost, but not quite.

Let's look at the case with 6 cards in the deck, and still 4 Farseeks, in the same way. If you draw it all out, there are now 6! different arrangements of all the cards (that's 720), and 4! arrangements of Farseeks in each distinct arrangement. So are there (6! / 4!) distinct arrangements of Farseeks? 6! / 4! comes out to 30, but there's actually only 15 distinct arrangements in a 6 card deck. 6! / 4! was close, but it should have been [6! / (2 * 4!)]. That gives us the correct answer. But what is this 2? Where did it come from? Where was it in the case of a 5 card deck? Well in the case of a five card deck, this variable actually was there, but you didn't need to see it because it was equal to 1. Anything times 1 is itself. So [5! / (1 * 4!)] is the more correct way of expressing the 5-card deck scenario. So what is this variable? Does it just increase by 1 every time we increase the deck by 1 card? Maybe, let's try it.

Let's try a 7 card deck now. Does [7! / (3 * 4!)] give us the correct number of distinct arrangements? Actually, no. Take my word for it to save you from counting a lot of permutations, but that comes to 70, when it needs to come to 35. So the equation has to be [7! / (6 * 4!)]. 6? So this magical weird variable has jumped from 1, to 2, to 6. Well that does in fact have a pattern, and it's 1!, 2!, 3!, and so on. It does indeed have to do with the number of cards that aren't Farseek, and we have to use the factorial of that to figure this out. By the way, I also calculated an 8 card deck scenario to make sure the sequence of "1!, 2!, 3!, ..." continued, and it did.

Finally, in our 60 card deck scenario, we can determine that the number of arrangements is [60! / ((60 - 4)! * 4!)]. Using our variables we mentioned at the top and simplifying, that would be [y! / ((y - x)!x!)]. I don't need the multiplication sign between the "!" and the "x" because order of operations allows that to make sense, and that's actually how it's properly written. So what does that result with in our 60 card deck? Surprisingly, only 487,635 distinct arrangements of Farseek in a 60 card deck (We said this was A, so A = 487,635). Using our logic from before, we must also determine the number of distinct arrangements in a 53 card deck, which in equation terms would look like [(y - n)! / ((y - n - x)!x!)] or [(60 - 7)! / ((60 - 7 - 4)! * 4!)]. That results in 292,825 arrangements where Farseek was not in the opening hand (We said this was B, so B = 292,825). Now that we have A and B, we can solve using our previous logic (A - B) / A.

(487,635 - 292,825) / 487,635 = 0.39949962574466557978816122714735~.

In percent terms, that's written as 39.949962574466557978816122714735~% chance that your opening hand will have at least one Farseek.

This equation would work given any number of cards in your deck, any given opening hand size, and any number of copies of Farseek in your deck to determine the probability of having it in your opening hand.

Thank you for reading, and I hope I was able to teach you something interesting. :)

Have a wonderful day.

ChiefBell says... #2

This is easy to figure out very roughly off the top of your head in order to just logic it out:

4 cards in 60 is 2 cards in 30 is 1 card in 15.

Therefore if you draw seven cards you would expect the chance to draw one of those 4 to be a tad under 50%.

Once you get into the maths you have to start looking at arrangements and you end up with the above working. But yeh! Good maths.

June 21, 2015 2:46 p.m.

HolyFalcon says... #3

Math. Glorious. Thanks for the equation.

Wait, you did math over the summer?

June 21, 2015 2:47 p.m.

June 21, 2015 2:52 p.m.

JakeHarlow says... #5

This is an awesome post. I learned a lot. Now I can explain to my friend who likes to run more than 60 cards the mathematical arguments against his folly! Awesome!

:)

June 21, 2015 2:52 p.m.

-Logician says... #6

ChiefBell Indeed, a tad under 50% can easily be assumed, and that's great and all. But man, I saw the 39.94% figure and I just needed to know. XD Thanks for the compliments.

Magicrafter You're very welcome. You say "summer" as though I'm still in school. I am in fact 23 years old, and actually solved this two years ago in August of 2013 right before I was about to start my fourth year of college. I guess you could say I did do this during my "summer," but I would hardly describe this as work. It's interesting to me, and was worth the use of my free time. Not sure why I waited until now to post it here. I guess I just had some inspiration.

June 21, 2015 2:56 p.m.

-Logician says... #7

DERPLINGSUPREME That made me laugh. :)

JakeHarlow Glad you like it! :) I'm definitely proud of it.

June 21, 2015 2:58 p.m.

bigguy99 says... #8

It's interesting that while you included the concept of permutations and combinations you didn't actually mention what they are in practicality or the terms themselves (math major speaking). Good stuff regardless. As much as I don't like probability or statistics, more people need to know about this.

June 21, 2015 3 p.m.

-Logician says... #9

bigguy99 Well as much as I was trying to explain myself and dumb it down as much as possible, I guess there is definitely room for improvement. Glad that a math major found the time to take a look at this. I'm not a math major myself, was a Digital Arts major, but I've always found interest in math. Thanks for stopping by, and I agree, this is a great tool to have.

June 21, 2015 3:03 p.m.

bigguy99 says... #10

I actually did some work into MtG probability myself, but that was more along the lines of hypergometric statistics involving the odds of drawing certain types of cards and in what order based on cracking fetches or not (which, as you can imagine, was incredibly tedious considering all the different cases of drawing fetchable lands, running out of fetchable lands, etc.), but that paper is long gone by now.

To sum it up, for everyone who cares: fetches make almost no impact on your odds of drawing more lands unless you're cracking them every single turn, and even then it's not as big of a change as you might think. Use fetches for mana-fixing, not deck-thinning.

June 21, 2015 3:06 p.m.

filledelanuit says... #11

I didn't have time to read your whole post but I'd stylized you just described the hyper geometric distribution.

It isn't feasible to actually celebrates probabilities involving fetches but there is a stimulation that some one did that's easy to find on google

June 21, 2015 3:13 p.m.

-Logician says... #12

bigguy99 That sounds like a big boy math problem. ;D

lordoftheshadows I'm having difficulty understanding your post.

June 21, 2015 3:17 p.m.

guessling says... #13

The original post sounds like it might be modeled with a hypergeometric probability distribution

June 21, 2015 3:18 p.m.

The_Raven says... #14

Well, didn't read it all, but... Why doesn't this just work?

60/4/7 = 2.14... 1/2.14 = 46.6667%. Which is not 39.94.....

June 21, 2015 3:40 p.m.

-Logician says... #15

guessling Maybe it is, but honestly, after a brief look at that article, it went a little bit over my head. I'd have to spend more time looking at that. Nonetheless, I am only just now hearing you guys talking about this "hypergeometric probability distribution" and have not really studied it or anything. I've also never taken a statistics class, and my math classes have only gone as high as trig, but I did take a Game Theory class. Needless to say, I don't really know a lot of the terms you would likely associate with this, and just used logic to come up with the answer.

June 21, 2015 3:42 p.m.

-Logician says... #16

NorthernRaven I guess the simplest answer is, "it just doesn't."

You have to consider all possible arrangements of the card you're focusing on and all of its copies within the deck, taking into consideration the distinct arrangements. Simply dividing those numbers, as you have concluded, isn't enough.

What you've concluded is that if you have a 60 card deck with four copies of Farseek, and those copies are divided perfectly equally between the 60 cards (one every 15 cards exactly), then a random sequential set of 7 cards taken from anywhere in the deck will result in a 46%~ chance of hitting a Farseek. Basically, your logic assumes that the Farseeks are always 15 cards apart, which isn't the case.

June 21, 2015 3:51 p.m.

The_Raven says... #17

Oh, I see! Didn't think about, that they then are exactly 15 cards away from each other! :) Thanks!

June 21, 2015 4:02 p.m.

-Logician says... #18

NorthernRaven No problem. Thank you for stopping by. :)

June 21, 2015 4:16 p.m.

Now it's been a number of years since I took stats but wouldn't using the probability button on a scientific calculator give you the result quicker?

I mean I can't recall the exact steps but it should be no different than the practice problems in stats where you look to find a jack in a deck of cards.

Aside from my questions on methodology very solid work. May I ask what your major was?

June 21, 2015 5:10 p.m.

bigguy99 says... #20

Calculators can do factorials, combinations, and permutations. Nothing else.

June 21, 2015 5:11 p.m.

Gattison says... #21

Excellent post. +1. I was always curious about the 39% figure, too, so thanks for figuring it out for me. =D

eyes2sky, check this out. you'll like this.

June 21, 2015 5:27 p.m.

-Logician says... #22

fadelightningmm bigguy99 summed up the answer to your question about calculators. My major was originally Digital Arts - Sound, or DA Sound as we called it. Basically it was music production. I was interested in music throughout college, and took extra music theory classes, but by the end of my junior year, the DA Sound major (which was an art degree) went through some changes and I switched my major to just Digital Arts, expanding into many things like web design, 3D modeling an animation, programming etc etc. By doing so, it is actually classified as a Bachelor of science, which is what I preferred. My senior research project was an Interactive algorithmic composition using a motion sensor camera to drive a piece of algorithmic music, with the twist that when you were in front of the camera, you didn't yet know that you were controlling the composition. Instead, you would later realize your agency in the creation of the music. I called the project Realization. That's the best I could describe profession.

Gattison Glad I could help!

June 21, 2015 5:55 p.m.

guessling says... #23

I am pretty sure that it could be calculated using the distribution with R software. I don't have that where I am right now, though.

June 21, 2015 7:35 p.m.

guessling says... #24

Some of the vocabulary words here are combination and permutation. The difference between them is whether order matters or not.

Another important vocabulary word is complement which is the opposite, basically, of an event.

I think that what you did was just subtract the complement of getting at least one farseek (which would be getting no farseeks) from the total probability of 1. This gives the probability of getting at least 1 (which could include up to all 4 farseeks but not none).

If we have:

  • N = 60 (60 cards in the deck)
  • K = 4 (letting farseek be our "success")
  • n = 7 (7 draws)
  • k = 0 (0 observed "success" - for the complement)

Then we would have 4C0 * (60-4)C(7-0) / 60C7

This would equal 4! / 4!0! * 56! /7!49! * 7!53!/60!

This simplifies to 56!53! / 49!60!

Which further simplifies to 53525150 / 60595857 = .60050037 ... so did I do it wrong?

Wait, this is the complement so 1 - .60050037 = .399499 ...

So yes, it seems that we can use the hypergeometric distribution here. It's nice to see a use for it as I remember barely using it when I studied these types of things years ago.

I like your use of something like mathematical induction logic.

Actually, I did it wrong at first because I used the pmf with k=1 success and got the probabilty of getting exactly one farseek, but what you were finding was the probability for at least one which is the complement of getting none at all - which is easier to calculate.

Thanks for this! I haven't "played math" like this in years!

June 21, 2015 8:52 p.m.

bigguy99 says... #25

When you find complements, you're not finding the value of getting exactly anything unless it's the most or least. You're finding at least or at most some amount, and so the complement of that is finding the values not included in the situation. In simpler terms, the above is true in that finding at least 1 is the complement of finding 0 because the possibilities are getting 0, 1, 2, 3, or 4 Farseeks. Other cases can include finding at least 3 Farseeks, the complement of which would be finding at most 2 (that covers all the possible cases). A lot of probability and combinatorics comes down to logic rather than actual mathematical computation.

June 21, 2015 9:03 p.m.

guessling says... #26

Yep re:complements, that's what I caught myself doing - probably shouldn't have admitted it, though ;-p

I do understand all that (as I explained it in my actual post there), actually ... I just didn't completely get what you were doing the first try - got it on the second try, though - which is what I posted here.

I guess that is why I went with teaching instead of full on PhD Stats: I care more about that teachable moment of admitting an earlier mistake for emphasis and am not good at "sounding smart" per-se. See, I didn't even have to tell you that I caught my own mistake before I posted this, but I did it because I thought that nuance was important for understanding - and a common error to make when dealing with these matters. So hopefully the gods will permit me to continue teaching and not force a destiny in academia on me!

You sound like one of my teachers in school "Probability is just intuition, either you get it or you don't" lol!

June 21, 2015 9:12 p.m.

eyes2sky says... #27

+1!

June 22, 2015 8:29 a.m.

-Logician says... #28

guessling I appreciate your enthusiasm!

eyes2sky Thanks for stopping by. :)

June 22, 2015 10:47 a.m.

Justin_Bop says... #29

Wow, nice job -Logician! This actually taught me a lot. Now here's the question; how do you calculate the percent of drawing two different cards you need in a deck? This seems 100 times more complicated, I tried to do the math but failed.

June 23, 2015 11:04 p.m.

filledelanuit says... #30

jrogers16 the hypergeometric distribution can be used to calculate those probabilities as well. This article explains it pretty well.

June 23, 2015 11:10 p.m.

Justin_Bop says... #31

Yep that would make sense sense lordoftheshadows thank you very much.

June 23, 2015 11:14 p.m.

Too lazy to read thread, so maybe someone already said this, but the easy way to do it is 1 - (56 choose 7) / (60 choose 7). Basically, 1 - probability of not having it in your opener.

EDIT: This works for any size deck, any number of a given card and any size opening hand by switching the numbers up.

EDIT 2: Darn.

July 21, 2015 8:43 a.m. Edited.

The key is to simplify the problem as much as possible.

"How many hands have at least one Farseek?"

"Well, doing it for 1, 2, 3 and 4 copies sounds hard. How many hands have no Farseeks?" (This is a lot easier to count)

"How many ways can I pick a hand with no Farseeks?" The answer is simply the 56 non-Farseek cards, choosing (combination, not permutation because the order doesn't matter) 7 of them for a hand.

"How many ways can I pick a hand?" The answer is simply 60 choosing 7.

Dividing those two numbers and subtracting from 1 (the complement is what we calculated) gives you your answer.

If you want to find the probability of having the four-of in your opener if you mulligan until you have it (this is similar to the Bazaar of Baghdad problem, except this excludes the mess that Serum Powder throws in), then it's a chain of conditional probability.

The answer is P(Farseek in seven card hand) + P(Farseek not in seven card hand) * P(Farseek in six card hand) + P(Farseek not in seven card hand) * P(Farseek not in six card hand) * P(Farseek in five-card hand), etc. all the way down to one card, which can be calculated just like my previous post.

The reason Serum Powder messes this up is because even though you know that you are exiling the seven cards you draw (or six or five, etc. depending on mulligans), you have no idea how many Bazaar of Baghdad were in those 7 cards. I don't think an expected value calculation works here either, because you also don't know how many Powders were in that hand.

@The_Raven Nice username change. :) The reason your method doesn't work is because the distribution of the number of Farseeks in a hand is not uniform. You are much more likely to have exactly two than exactly four copies of it. Similarly, the probability of having some opening hands is less than that of others. Having seven Forests in your hand is less likely than having 6 and a Plains. Your calculation comes down to 28/60, but the issue is that you treat every copy of your four-of as the same without considering the condition that one copy of it is already in hand.

July 21, 2015 9:14 a.m.

filledelanuit says... #34

GlistenerAgent what you described is quite literally a layman's definition of the hyper-geometric distribution. What you described is how what the hyper geometric distribution does when applied to MTG hands.

Also, nice necro.

July 21, 2015 11:08 a.m.

It's too late, unfortunately. I'm already halfway across the River.

July 21, 2015 11:15 a.m.

This discussion has been closed