diff --git a/docs/conceptual_guide.md b/docs/conceptual_guide.md index e31695e..88f5b24 100644 --- a/docs/conceptual_guide.md +++ b/docs/conceptual_guide.md @@ -284,7 +284,7 @@ The complement of a simple event is given by ```{math} :label: eq-complement-product-sigma-algebra -(A \times B)^c = (A^c \times B) \cup (A \times B) \cup (A \times B^c). +(A \times B)^c = (A^c \times B) \cup (A \times B^c) \cup (A^c \times B^c). ``` {cite}`hunter2011data` ```` diff --git a/src/random_events/variable.py b/src/random_events/variable.py index c055d8f..8d2f00d 100644 --- a/src/random_events/variable.py +++ b/src/random_events/variable.py @@ -1,6 +1,8 @@ +from abc import abstractmethod + from typing_extensions import Self, Type, Dict, Any, Union, Optional -from .interval import Interval, SimpleInterval, reals +from .interval import Interval, reals from .set import Set, SetElement from .sigma_algebra import AbstractCompositeSet from .utils import SubclassJSONSerializer @@ -49,6 +51,14 @@ def to_json(self) -> Dict[str, Any]: def _from_json(cls, data: Dict[str, Any]) -> Self: return cls(data["name"], AbstractCompositeSet.from_json(data["domain"])) + @property + @abstractmethod + def is_numeric(self): + """ + :return: Rather, this variable has a numeric domain or not. + """ + raise NotImplementedError + class Continuous(Variable): """ @@ -61,6 +71,10 @@ class Continuous(Variable): def __init__(self, name: str, domain=None): super().__init__(name, reals()) + @property + def is_numeric(self): + return True + class Symbolic(Variable): """ @@ -93,6 +107,10 @@ def __init__(self, name: Optional[str] = None, domain: Union[Type[SetElement], S def domain_type(self) -> Type[SetElement]: return self.domain.simple_sets[0].all_elements + @property + def is_numeric(self): + return False + class Integer(Variable): """ @@ -104,3 +122,7 @@ class Integer(Variable): def __init__(self, name: str, domain=None): super().__init__(name, reals()) + + @property + def is_numeric(self): + return True \ No newline at end of file