I'm creating a mod to a video game that will list the percent chance of an event happening. I know how to get individual percentages, but not a total percentage of the events.
The Problem:
So there is this pool, or an array of possible outcomes.
Classic starts in this pool so hence it's always in the pool.
Bifurcated has a 15% chance of being added to that pool
Golden has a 0.3% chance of being added
Meaty has a 10% multiplied by the amount of X upgraded, to be added. X=(max 3, min 0)
Caramelized has a 2% chance to be added.
And if another certain upgrade has been bought, all BUT the Classic get their checks done again, so there is a chance that there is : two, one, or none of each of the four being added to the pool.
Now the game takes this pool, and chooses one randomly from it. They have equal chances once in the pool. But not equal chances to enter the pool.
My Attempts
I'm having a hard time figuring out how to write the math to automatically calculate the chances are for each item. For example, if it was just Classic and Bifurcated a 15% chance to be added then a 50% chance to be selected would be 7.5% chance while classic has a 92.5% chance. But once I get to the possibility of a third being added, how do I calculate that?
After a lot of thinking, I came up with this list of percentages of JUST adding them to the random pool.
//chances of just ADDING bifurcated to the pool.
//RAN ONCE
ranOnce_addOne = 0.15;
ranOnce_addNone = 0.85;
//RAN TWICE
ranTwice_addNone = 0.7225;
ranTwice_addTwo = 0.0225;
ranTwice_addOne = 0.225;
I had this, and didn't know where to go from here. For example if we only checked to add bifurcated to the pool once, I could figure it out, but the fact there are times when the amount in the pool could go from 1 to 9 (though statistically unlikely).
Now I have access to the amount of X and whether the checks get ran twice or not. But I have no idea how to code something that will tell me what is the chances of all this?
I originally asked on StackOverflow as I'm a programmer not a math guy, so I did some searches on this site to see if my question was already answered, but didn't find any nor could I understand half of what I read. Sorry
Let $\widetilde S$ be the "pool" of possible outcomes that you call "Classic" etc., and let these possible outcomes be denoted as $A_1,...,A_k$. The interesting feature here is that $\widetilde S$ is a random subset of $\Omega=\{A_1,...,A_k\}$, each element being included (resp. excluded) with probability $p_i:=P(A_i)$ (resp. $1-p_i$). Thus, first $\widetilde S$ is chosen randomly, then an element $X$ is chosen uniformly at random from $\widetilde S$.
A useful coding scheme is to represent each subset by a binary string $(b_1...b_k)$, with $b_i$ equaling $1$ (or $0$) according to whether element $A_i$ is (or is not) included in the subset. Thus the subset coded by $(b_1...b_k)$ has probability given by
$$P(b_1...b_k)=p_1^{(b_1)}...p_k^{(b_k)}$$
with the special notation
$$p^{(b)}:=\begin{cases} p &\text{if $b=1$}\\ 1-p &\text{if $b=0$}\end{cases}$$
Then
$$\begin{align}P(X=A_i) &= \sum_S P(X=A_i\mid \widetilde S=S)\ P(\widetilde S=S)\\[1ex] &= \sum_{S\ni A_i} {1\over |S|}\ P(\widetilde S=S)\\[1ex] &= \sum_{(b_1..b_k);b_i=1} {p_1^{(b_1)}...p_k^{(b_k)}\over \sum_i b_i}\\[1ex] \end{align}$$
Here's a Python program that does this:
Example: