[Help] Hyper-geometric Distribution for deck of cards
Hello, I'm in the process of designing a tabletop RPG with a feature that requires drawing from a deck of cards. I haven't decided anything yet in terms of the quantity of the types of cards in the deck, this is the very early phases. I was just looking into the math of it. My math background is basically just the three calculus classes I took in University, and so I never did stuff like this.
I thought I was doing things correctly, but when I plugged the numbers into my spreadsheet, they don't make sense to me.
So, for example, a deck of cards with a total of 40 cards has 39 Hearts and 1 Spade.
The point is, when a character's life goes to 0, the player will shuffle the deck and draw the top 3 cards. If one of those cards is a Spade, then the character dies.
Obviously, this ratio gives a very low chance of dying. But, the point is that every time the player levels up, a Heart is replaced with a Spade. The idea is to be more forgiving while the player is a lower level and less as the player levels up, considering it'll be much harder for a player's life to become 0 at a higher level.
So, I researched for the math that can show me the percent chance of dying per character level. I googled the classic colored marble out of the sack problem and discovered the hyper-geometric distribution formula and was pretty darn sure that's what I was looking for.
I won't post the formula here, I assume the person who can help me knows it already, or you can just google it. Here are the values though:
- N = 40 total number of cards
- m = x the number of spades in the deck (1..20 is what i'm presenting here)
- k = 1 the number of Spades in the drawn cards. The thing I'm getting the % of.
- n = 3 the number being drawn
The problem comes as the number of Spades(m) in the deck gets larger. I used a spreadsheet to plug in 1..20. At 14, it peaks at 46.05%. Then it falls off to 38.46% at 20. This doesn't make sense to me. Wouldn't the probability of getting 1(k) Spade in the 3 drawn cards(n) only go up as more of them are populated into the deck? I don't get it.
I plugged this into WolframAlpha:
graph ((x ncr 1)*((40 - x) ncr (3 - 1)))/(40 ncr 3)
Which matches the formula I plugged into the spreadsheet, and it checks out. It's a wave that comes in from -infinity, peaks at ~14, curves back down to 0 at ~40 and raises back up to +infinity.
I then plugged in a really high number just to see what would happen. It says that if I have 40 cards made of 2 Hearts and 38 Spades, there's a 0.38% chance of getting 1(k) Spade in 3(n) drawn cards. That's obviously incorrect.
What am I doing wrong? What formula should I be using? And sorry if the answer is obvious, I just don't see it.
Again, as far as the game goes, the values are not set in stone. In fact, I'm most likely NOT going to be using these quantity of cards. I just want to make sure that I'm using the right formula, so when I do change the values, I'm not steered in the wrong direction.
Thanks to anyone who helps.
EDIT: Formatting
Posted Aug 29, 2016, 11:26 PM UTC · edited