From 3f0a924882c82459f93d72e6ab0570eeb5b0cd4f Mon Sep 17 00:00:00 2001 From: Tom Schierenbeck Date: Fri, 26 Jan 2024 13:57:03 +0100 Subject: [PATCH] Updated representation. --- src/probabilistic_model/distributions/distributions.py | 10 +++++++++- src/probabilistic_model/distributions/gaussian.py | 4 ++-- src/probabilistic_model/distributions/uniform.py | 2 +- .../probabilistic_circuit/distributions/uniform.py | 1 - 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/probabilistic_model/distributions/distributions.py b/src/probabilistic_model/distributions/distributions.py index 950f18e..e18d163 100644 --- a/src/probabilistic_model/distributions/distributions.py +++ b/src/probabilistic_model/distributions/distributions.py @@ -20,6 +20,13 @@ class UnivariateDistribution(ProbabilisticModel): def __init__(self, variable: Variable): super().__init__([variable]) + @property + def representation(self) -> str: + """ + The symbol used to represent this distribution. + """ + return self.__class__.__name__ + @property def variable(self) -> Variable: """ @@ -216,6 +223,7 @@ def plot(self) -> List: return traces + class DiscreteDistribution(UnivariateDistribution): """ Abstract base class for univariate discrete distributions. @@ -452,7 +460,7 @@ def __hash__(self): @property def representation(self): - return f"DiracDelta({self.location}, {self.density_cap})" + return f"δ({self.location}, {self.density_cap})" def __copy__(self): return self.__class__(self.variable, self.location, self.density_cap) diff --git a/src/probabilistic_model/distributions/gaussian.py b/src/probabilistic_model/distributions/gaussian.py index b7f52c1..88ede9d 100644 --- a/src/probabilistic_model/distributions/gaussian.py +++ b/src/probabilistic_model/distributions/gaussian.py @@ -141,7 +141,7 @@ def __eq__(self, other): @property def representation(self): - return f"\N{MATHEMATICAL SCRIPT CAPITAL N}(\u03BC={self.mean},\u03C3\u00b2={self.variance})" + return f"N({self.mean}, {self.variance})" def __copy__(self): return self.__class__(self.variable, self.mean, self.variance) @@ -281,7 +281,7 @@ def __eq__(self, other): @property def representation(self): - return f"\N{MATHEMATICAL SCRIPT CAPITAL N}(\u03BC={self.mean},\u03C3\u00b2={self.variance}|{self.interval})" + return f"N({self.mean},{self.variance} | {self.interval})" def __copy__(self): return self.__class__(self.variable, self.interval, self.mean, self.variance) diff --git a/src/probabilistic_model/distributions/uniform.py b/src/probabilistic_model/distributions/uniform.py index 18bc234..b829a10 100644 --- a/src/probabilistic_model/distributions/uniform.py +++ b/src/probabilistic_model/distributions/uniform.py @@ -107,7 +107,7 @@ def __eq__(self, other): @property def representation(self): - return f"\N{MATHEMATICAL SCRIPT CAPITAL U}{self.interval}" + return f"U({self.interval})" def __copy__(self): return self.__class__(self.variable, self.interval) diff --git a/src/probabilistic_model/probabilistic_circuit/distributions/uniform.py b/src/probabilistic_model/probabilistic_circuit/distributions/uniform.py index 253d926..e16110f 100644 --- a/src/probabilistic_model/probabilistic_circuit/distributions/uniform.py +++ b/src/probabilistic_model/probabilistic_circuit/distributions/uniform.py @@ -23,7 +23,6 @@ def __init__(self, variable: Continuous, interval: portion.Interval, parent=None super().__init__(variable, interval) ContinuousDistribution.__init__(self, variable, parent=parent) - def conditional_from_simple_interval(self, interval: portion.Interval) -> Tuple[ Optional[Union[DeterministicSumUnit, Self]], float]: