// that does not rely on the particular implementation"s storage
// mechanism. Here is one way.
//
outcomes = list(self.sample_space())
zero = self.ops.zero
probs = [zero] * len(outcomes)
_outcomes = self.outcomes
_pmf = self.pmf
i, j = 0, 0
while j < len(_pmf):
if outcomes[i] == _outcomes[j]:
probs[i] = _pmf[j]
j += 1
i += 1
else:
outcomes = self.outcomes
probs = self.pmf
return izip(outcomes, probs)
////// We choose to implement only scalar multiplication and distribution
After Change
raise ditException("Invalid mode.")
if mode == "pmf":
for x in izip(self.outcomes, self.pmf):
yield x
elif mode == "atoms":
// Then we want to iterate over the sample space.
//
// There are many ways to do this, but we need to do it in a way