I like Old Marksman's earlier post about risk management. Probabilities are wonderful predictive tools about the likelihood of things happening. However, they always coalesce to either zero or one - either the thing being predicted happens during some time interval, or it does not.
For the 0% scenario, you need zero rounds. Either you are not ever in a self-defense situation, or you are in a self-defense situation and there is a better option open to you than use of a handgun.
So you only need to analyze the 100% version, which you would word thus: given that you are in a self-defense situation and the best approach available to you is to use a firearm, what sort of firearm and how many rounds are needed to survive the encounter?
There is, unfortunately, no way to avoid "what-ifs" because you are planning for a future event that may unfold in ways you do not anticipate. You will have to make some assumptions, informed as best you can by any historical information you have, or at least well-reasoned thoughts.
So lets make the following assumptions - you need to survive a situation where there are two armed assailants who have targeted you as a victim. Assumption 2: 3 hits to important areas with an effective caliber is sufficient to stop an attacker (I realize this is subject to what-ifs, but you have to pick something). So in that situation, you need 6 hits. Assume your ability to hit an "important area" with any given round is 50%. So now you need 12 rounds of an effective caliber, that you can deliver to two targets in a short enough period of time that they can't put three effective rounds into you.
I am not saying that 12 rounds is the magic number, it is just what comes out of that particular calculation based on those assumptions. If you want to make different assumptions, then the result is different. If you think 2 rounds per assailant is enough, then you only need 8. If you think your hit rate to important areas is 66% and 2 hits is enough, then you need 6. If it's just one assailant, then you may be down to 3.
Statistically, there are plenty of situations where having ANY gun at all is sufficient (i.e. they see you draw and they break off the attack), or one round is sufficient (you shoot and they break off the attack, whether or not you hit someone.)
So you have to truly determine which scenario you are wanting to have "enough" for, and what your reasonable assumptions are.
Clearly in a real situation, you want plenty of the most effective round that you can deliver to important areas of your assailant(s) quickly enough to cause them to break off the attack, either voluntarily or due to incapacitation.
You have to shade that versus what you will actually be willing to carry. If your analysis says you need a 17-round 9mm then yes, you need a double-stack full-size auto, and you should be willing to figure out how to carry that, if you truly want to be able to protect against that sort of threat possibility.
Most of the time, for most people, zero rounds is enough for their entire lives. If that is the probability you want to prepare for, then don't carry anything at all.