I want to use Mathematica to show which subsets of a power set are required to calculate the plausibility for a given set in a power set. This has lead me to compute a summation with a Do and an If function in Mathematica. I would like to know if there is a neater way.

The plausibility $pl(A)$ is the sum of all the masses of the sets B that intersect the set of interest A:

$pl(A) = \sum_{B|B \cap A \ne \emptyset}^{ } {m(B)}$

This is based on the Wikipedia example https://en.wikipedia.org/wiki/Dempster%E2%80%93Shafer_theory.

To calculate summation I used the following Mathematica code:

powerset = Subsets[{r,y,g}]

This returns:


If I want to calculate the plausibility of 'Red' then I need to sum the masses of the following sets:


This returns:


Is there a better way I can get Mathematica to return this list of sets?


1 Answer 1


From your code, you appear to be looking for subsets in the power set that contain a certain symbol. That's a job for Selector Cases:

Select[Subsets[{r, y, g}], MemberQ[r]]
Cases[Subsets[{r, y, g}], {___, r, ___}]

Both return the same:

{{r}, {r, y}, {r, g}, {r, y, g}}
  • $\begingroup$ Maybe a silly question, but wouldn't all sets of Subsets[{r,y,g}] that have r in it be just the same as Subsets[{y,g}] with r appended to each subset? $\endgroup$ Apr 18, 2019 at 14:35
  • $\begingroup$ @SjoerdSmit Yes I think so. However, I am not sure that I understand the theory behind what OP was doing, so I simply translated the "algorithm" that he was using to more idiomatic MMA code. $\endgroup$
    – MarcoB
    Apr 18, 2019 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.