Given a sequences of events with probabilities between 0.0 and 1.0, generate and derive the probability of each combination occurring. You may presume that a sequence of numbers is provided in whatever construct your chosen language provides.
Here's an example; you may presume that the length of the sequence's combinations fit into memory:
{ 0.55, 0.67, 0.13 }
The program shall print each combination and the associated probability of that sequence occurring. A 1 shall denote that the event in that index of the input sequence occurred and a 0 shall denote that that event did not occur. The desired output is below (I don't care about printing the work, that's just for informational purposes of the algorithm):
[0,0,0] = (1 - 0.55) * (1-0.67) * (1-0.13) = 0.129195
[0,0,1] = (1 - 0.55) * (1-0.67) * (0.13) = 0.019305
[0,1,0] = (1 - 0.55) * (0.67) * (1-0.13) = 0.262305
[0,1,1] = (1 - 0.55) * (0.67) * (0.13) = 0.039195
[1,0,0] = (0.55) * (1-0.67) * (1-0.13) = 0.157905
[1,0,1] = (0.55) * (1-0.67) * (0.13) = 0.023595
[1,1,0] = (0.55) * (0.67) * (1-0.13) = 0.320595
[1,1,1] = (0.55) * (0.67) * (0.13) = 0.047905
This problem is tangentially related to calculating a "Cartesian product".
Remember, this is code-golf, so the code with the fewest number of bytes wins.
[0.129195, 0.019305, 0.262305, ..., 0.047905]
be enough as output or are the[0,0,0], [0,0,1], ...
necessary? \$\endgroup\$