def _make_key(self, key): gamble, event = BelFunc._make_key(self, key) gamble_event = self.pspace.make_event(gamble) if not gamble_event.is_singleton(): raise ValueError('not a singleton') if not event.is_true(): raise ValueError('must be unconditional') return gamble, event
def get_lower(self, gamble, event=True, algorithm='linvac'): r"""Calculate the lower expectation of a gamble conditional on an event, by the following formula: .. math:: \underline{E}(f|A)= \frac{ (1-\epsilon)\sum_{\omega\in A}p(\omega)f(\omega) + \epsilon\min_{\omega\in A}f(\omega) }{ (1-\epsilon)\sum_{\omega\in A}p(\omega) + \epsilon } where :math:`\epsilon=1-\sum_{\omega}\underline{P}(\omega)` and :math:`p(\omega)=\underline{P}(\omega)/(1-\epsilon)`. Here, :math:`\underline{P}(\omega)` is simply:: self[{omega: 1}, True][0] This method will *not* raise an exception, even if the assessments are incoherent (obviously, in such case, :math:`\underline{E}` will be incoherent as well). It will raise an exception if not all lower probabilities on singletons are defined (if needed, extend it first). """ # default algorithm if algorithm is None: algorithm = 'linvac' # other algorithms? if algorithm != 'linvac': return BelFunc.get_lower(self, gamble, event, algorithm) gamble = self.make_gamble(gamble) event = self.pspace.make_event(event) epsilon = 1 - sum(self[{omega: 1}, True][0] for omega in self.pspace) return ((sum(self[{ omega: 1 }, True][0] * gamble[omega] for omega in event) + epsilon * min(gamble[omega] for omega in event)) / (sum(self[{ omega: 1 }, True][0] for omega in event) + epsilon))
def get_lower(self, gamble, event=True, algorithm='linvac'): r"""Calculate the lower expectation of a gamble conditional on an event, by the following formula: .. math:: \underline{E}(f|A)= \frac{ (1-\epsilon)\sum_{\omega\in A}p(\omega)f(\omega) + \epsilon\min_{\omega\in A}f(\omega) }{ (1-\epsilon)\sum_{\omega\in A}p(\omega) + \epsilon } where :math:`\epsilon=1-\sum_{\omega}\underline{P}(\omega)` and :math:`p(\omega)=\underline{P}(\omega)/(1-\epsilon)`. Here, :math:`\underline{P}(\omega)` is simply:: self[{omega: 1}, True][0] This method will *not* raise an exception, even if the assessments are incoherent (obviously, in such case, :math:`\underline{E}` will be incoherent as well). It will raise an exception if not all lower probabilities on singletons are defined (if needed, extend it first). """ # default algorithm if algorithm is None: algorithm = 'linvac' # other algorithms? if algorithm != 'linvac': return BelFunc.get_lower(self, gamble, event, algorithm) gamble = self.make_gamble(gamble) event = self.pspace.make_event(event) epsilon = 1 - sum(self[{omega: 1}, True][0] for omega in self.pspace) return ( (sum(self[{omega: 1}, True][0] * gamble[omega] for omega in event) + epsilon * min(gamble[omega] for omega in event)) / (sum(self[{omega: 1}, True][0] for omega in event) + epsilon) )