# Marginalization of conditional probability

I am working through these examples of computations on Bayesian networks and came across this claim (part of the last sample computation):

$$P(E=e|A=a) = \sum_{c \in C} P(E=e, C=c | A=a)$$

I am newly familiar with marginalization, but I thought that it was:

$$P(A=a) = \sum_{b \in B} P(A=a,B=b) = \sum_{b \in B} P(A=a|B=b)P(B=b)$$

If the first equation is true, can someone explain? I have tried searching for "marginalizing conditional probability" but have not found anything that seems similar.

By definition of conditional probability* we have that:

$$P(E=e|A=a)=\frac{P(E=e,A=a)}{P(A=a)}=\frac{\sum_{c}P(E=e,C=c,A=a)}{P(A=a)}$$

In the last step I used marginalization over $c$. Then, again using the definition of conditional probability, this is equal to:

$$\sum_{c}P(E=e,C=c|A=a)$$.

*Definition of conditional probability:

$$P(x_1,...,x_n|y_1,...,y_m)=\frac{P(x_1,...,x_n,y_1,...,y_m)}{P(y_1,...,y_m)}$$

Conditional probabilities are a probability measure meaning that they satisfy the axioms of probability, and enjoy all the properties of (unconditional) probability.

The practical use of this pontification is that any rule, theorem, or formula that you have learned about probabilities are also applicable if everything is assumed to be conditioned on the occurrence of some event. For example, knowing that $$P(B^c) = 1 - P(B)$$ allows us to immediately conclude that $$P(B^c\mid A) = 1 - P(B\mid A)$$ is a valid result without going through writing out the formal definitions and completing a proof of the result. So apply this idea to the formula $$P(E) = \sum_i P(E \cap C_i)$$ where $C_1, C_2, \cdots$ is a partition of the sample space $\Omega$ into disjoint subsets (and so $(E \cap C_1)$, $(E \cap C_2), \cdots$ is a partition of $E$ into disjoint subsets). Conditioning everything on $A$ gives us $$P(E\mid A) = \sum_i P(E \cap C_i\mid A)$$ which is your formula in slightly different notation.