I would like to know how I can write a Mathematica code for the Inclusion–exclusion principle.
The formulas governing it are:
$ P(\bigcup_{i=1}^n A_i)=\sum_{k=1}^n (-1)^{k-1} \sum_{\substack{I\subset\{1,2,...,n\}\\|I|=k} }P(\bigcap_{i\in I} A_i) $
where $P(A_i)$ denotes the probability of the event $A_i$. Similarly for cardinality of union we have:
$ |\bigcup_{i=1}^n A_i|=\sum_{k=1}^n |A_k|- \sum_{1\leq i_1 or in closed form $|\bigcup_{i=1}^n A_i|=\sum_{\substack{\emptyset\neq I\subset\{1,2,...,n\}\\|I|=k} }(-1)^{|I|-1} |\bigcap_{i\in I} A_i|$
Comments
Post a Comment