2020 from ...base .functions import __module__
2121except ModuleNotFoundError :
2222 import pyximport
23+
2324 pyximport .install ()
2425finally :
2526 from ...base .intervals import R , ContinuousSet , RealSet , NumberSet
@@ -112,10 +113,10 @@ def label2value(
112113 @classmethod
113114 def equiv (cls , other ):
114115 return (
115- issubclass (other , Numeric ) and
116- cls .__name__ == other .__name__ and
117- cls .values == other .values and
118- cls .labels == other .labels
116+ issubclass (other , Numeric ) and
117+ cls .__name__ == other .__name__ and
118+ cls .values == other .values and
119+ cls .labels == other .labels
119120 )
120121
121122 @property
@@ -175,18 +176,17 @@ def is_dirac_impulse(self) -> bool:
175176 """Checks if this distribution is a dirac impulse."""
176177 return len (self ._quantile .cdf .intervals ) == 2
177178
178- def mpe (self ) -> (float , RealSet ):
179+ def mpe (self ) -> (RealSet , float ):
179180 return self ._mpe (self .value2label )
180181
181- def _mpe (self , value_transform : Optional [Callable ] = None ) -> (float , NumberSet ):
182+ def _mpe (self , value_transform : Optional [Callable ] = None ) -> (NumberSet , float ):
182183 """
183184 Calculate the most probable configuration of this quantile distribution.
184- :return: The likelihood of the mpe as float and the mpe itself as RealSet
185+ :return: The mpe itself as RealSet and the likelihood of the mpe as float
185186 """
186187 value_transform = ifnone (value_transform , lambda _ : _ )
187188 _max = max (f .value for f in self .pdf .functions )
188189 return (
189- _max ,
190190 value_transform (
191191 RealSet (
192192 [
@@ -196,7 +196,7 @@ def _mpe(self, value_transform: Optional[Callable] = None) -> (float, NumberSet)
196196 if function .value == _max
197197 ]
198198 ).simplify ()
199- )
199+ ), _max
200200 )
201201
202202 def _fit (
@@ -236,8 +236,8 @@ def _p(self, value: Union[numbers.Number, NumberSet]) -> numbers.Real:
236236 if probspace .isdisjoint (value ):
237237 return 0
238238 probmass = (
239- (self .cdf .eval (value .upper ) if value .upper != np .PINF else 1. ) -
240- (self .cdf .eval (value .lower ) if value .lower != np .NINF else 0. )
239+ (self .cdf .eval (value .upper ) if value .upper != np .PINF else 1. ) -
240+ (self .cdf .eval (value .lower ) if value .lower != np .NINF else 0. )
241241 )
242242 if not probmass :
243243 return probspace in value
@@ -524,10 +524,10 @@ def _moment(
524524 # We have to "stretch" the pdf value over the interval in label space:
525525 function_value = function .value * interval .width / interval_ .width
526526 result += (
527- (
528- pow (interval_ .upper - center , order + 1 )
529- - pow (interval_ .lower - center , order + 1 )
530- ) * function_value / (order + 1 )
527+ (
528+ pow (interval_ .upper - center , order + 1 )
529+ - pow (interval_ .lower - center , order + 1 )
530+ ) * function_value / (order + 1 )
531531 )
532532 return result
533533
0 commit comments