Skip to content

Commit

Permalink
Updated representation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsch420 committed Jan 26, 2024
1 parent aa89c64 commit 3f0a924
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/probabilistic_model/distributions/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -216,6 +223,7 @@ def plot(self) -> List:

return traces


class DiscreteDistribution(UnivariateDistribution):
"""
Abstract base class for univariate discrete distributions.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/probabilistic_model/distributions/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/probabilistic_model/distributions/uniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]:

Expand Down

0 comments on commit 3f0a924

Please sign in to comment.