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:
Do[If[Intersection[{r},i]!={},Print[i]],{i,powerset}]
powerset = Subsets[{r,y,g}]
This returns:
{{},{r},{y},{g},{r,y},{r,g},{y,g},{r,y,g}}
If I want to calculate the plausibility of 'Red' then I need to sum the masses of the following sets:
Do[If[Intersection[{r},i]!={},Print[i]],{i,powerset}]
This returns:
{r}
{r,y}
{r,g}
{r,y,g}
Is there a better way I can get Mathematica to return this list of sets?