Closed equaeghe closed 13 years ago
Currently, a Prob is taken to be a LowProb defined on singletons, and whose natural extension is calculated via expectation.
So:
In other words, with the current design, this is expected behaviour. I've updated the documentation to make this more clear:
https://github.com/mcmtroffaes/improb/commit/0a23d7cc8df9bd85056fd09d26e5ecb39ddfb7a7
Suggestions?
I've just done another commit which I think addresses the extend problems in an elegant way:
https://github.com/mcmtroffaes/improb/commit/cd7f7c4853a7f1a51bcdc802e2f2a32459c55094
You can now do prob.extend(algorithm='linprog') without having an exception raised. Of course the resulting probability will generally not be valid (unless we implement another extend method specifically for probabilities, e.g. 'uniform', which distributes the remaining mass uniformly?).
Printing of incompletely specified probability measures:
https://github.com/mcmtroffaes/improb/commit/08fbdaa8e204a0e873f6d37b033b285ab291df17
Linear extension for Prob:
https://github.com/mcmtroffaes/improb/commit/1bb3b872e9396fc80741c5ba4ed8a2e9218266c6
I think this now addresses everything, so closing.
Hmm, I'm afraid I wasn't clear about what I meant exactly:
Yes to all:
As a side effect of the refactoring, extending a Prob using the (now non-default) linprog algorithm does raise a clearer exception:
from improb.lowprev.prob import Prob p = Prob(3) p.extend(algorithm='linprog') Traceback (most recent call last): ... ValueError: can only specify precise prevision
Extending an empty LowProb obviously results in a vacuous lower probability (this has always been the case) - if you see anything different, then that's a bug, but it works for me:
from improb.lowprev.lowprob import LowProb p = LowProb(3, number_type='fraction') p.extend() print(p) : 0 0 : 0 1 : 0 2 : 0 0 1 : 0 0 2 : 0 1 2 : 0 0 1 2 : 1
I'm not exactly sure whether this is an issue or a "we can't deal with every stupid corner case"; anyhow:
Traceback (most recent call last): File "", line 1, in
File "improb/lowprev/prob.py", line 49, in str
[self[{omega: 1}, True][0] for omega in self.pspace]))
File "improb/lowprev/lowpoly.py", line 278, in getitem
return self._mapping[self._make_key(key)]
KeyError: (Gamble(pspace=PSpace(['a', 'b', 'c']), mapping={'a': 1, 'b': 0, 'c': 0}), Event(pspace=PSpace(['a', 'b', 'c']), elements=set(['a', 'c', 'b'])))
Traceback (most recent call last): File "", line 1, in
File "improb/lowprev/lowprob.py", line 208, in extend
algorithm=algorithm)
File "improb/lowprev/lowpoly.py", line 736, in extend
lprev, uprev = self[gamble, event]
File "improb/lowprev/lowpoly.py", line 278, in getitem
return self._mapping[self._make_key(key)]
File "improb/lowprev/linvac.py", line 57, in _make_key
raise ValueError('not a singleton')
ValueError: not a singleton