From db7ee8a50457c196fa838b3c0f55cd64c8bdee79 Mon Sep 17 00:00:00 2001 From: Tom Schierenbeck Date: Mon, 17 Jun 2024 16:56:20 +0200 Subject: [PATCH] Started to work on book. --- book/Tomato.png | Bin 0 -> 787 bytes book/_config.yml | 27 +++- book/_toc.yml | 4 +- book/conceptual-guide.md | 229 +++++++++++++++++++++++++++++ book/deploy.yml | 52 +++++++ book/intro.md | 13 +- book/logo.png | Bin 9854 -> 0 bytes book/markdown-notebooks.md | 53 ------- book/markdown.md | 55 ------- book/notebooks.ipynb | 122 --------------- book/references.bib | 60 ++------ book/requirements.txt | 2 + src/random_events/interval.py | 2 +- src/random_events/sigma_algebra.py | 2 +- 14 files changed, 322 insertions(+), 299 deletions(-) create mode 100644 book/Tomato.png create mode 100644 book/conceptual-guide.md create mode 100644 book/deploy.yml delete mode 100644 book/logo.png delete mode 100644 book/markdown-notebooks.md delete mode 100644 book/markdown.md delete mode 100644 book/notebooks.ipynb diff --git a/book/Tomato.png b/book/Tomato.png new file mode 100644 index 0000000000000000000000000000000000000000..b780415a1c2acdfe65eacebd37c8ee0bddb84297 GIT binary patch literal 787 zcmeAS@N?(olHy`uVBq!ia0vp^$AEY@2OE&IQ-A0Lq!^2X+?^QKos)UVz`%6Y)5S5Q zV$R#U8-0&B2si}t1u_YmxSG1OxP&+d3tVJo@tE-EKyk)X<0}1aYqp+?m#)}SzUz_9 z{O)(vQ6=$h>%PY^#3&^?2(YnW5C%;jvOmu_e);v|Nvt;Zdwlf1-_}hz-k`w4aR>`> zjO$!-&6D|?ld+m5z}7N*ulR-=tL!T*rRqzJaho&!lV|_M@7wQI6mL8jVc z zdmdKI;Vst0DZ6pwg3PC literal 0 HcmV?d00001 diff --git a/book/_config.yml b/book/_config.yml index 78bc016..dea80da 100644 --- a/book/_config.yml +++ b/book/_config.yml @@ -1,9 +1,14 @@ -# Book settings -# Learn more at https://jupyterbook.org/customize/config.html +####################################################################################### +# A default configuration that will be loaded for all jupyter books +# See the documentation for help and more options: +# https://jupyterbook.org/customize/config.html -title: Random Events -author: Tom Schierenbeck -logo: logo.png +####################################################################################### +# Book settings +title : Random Events # The title of the book. Will be placed in the left navbar. +author : Tom Schierenbeck # The author of the book +copyright : "2024" # Copyright year to be placed in the footer +logo : Tomato.png # A path to the book logo # Force re-execution of notebooks on each build. # See https://jupyterbook.org/content/execute.html @@ -21,12 +26,20 @@ bibtex_bibfiles: # Information about where the book exists on the web repository: - url: https://github.com/executablebooks/jupyter-book # Online location of your book + url: https://github.com/tomsch420/Random Events # Online location of your book path_to_book: docs # Optional path to your book, relative to the repository root - branch: master # Which branch of the repository should be used when creating links (optional) + branch: main # Which branch of the repository should be used when creating links (optional) # Add GitHub buttons to your book # See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository html: use_issues_button: true use_repository_button: true + +sphinx: + extra_extensions: + - sphinx_proof + +parse: + myst_enable_extensions: + - amsmath \ No newline at end of file diff --git a/book/_toc.yml b/book/_toc.yml index 74d5c71..b72e2b2 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -4,6 +4,4 @@ format: jb-book root: intro chapters: -- file: markdown -- file: notebooks -- file: markdown-notebooks +- file: conceptual-guide \ No newline at end of file diff --git a/book/conceptual-guide.md b/book/conceptual-guide.md new file mode 100644 index 0000000..c6a8b09 --- /dev/null +++ b/book/conceptual-guide.md @@ -0,0 +1,229 @@ +--- +jupytext: + cell_metadata_filter: -all + formats: md:myst + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.11.5 +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- + +# Conceptual Guide + +In probability theory, sigma algebras play a fundamental role by formalizing the notion of events within a sample space. +This chapter delves into the development and application of a specific sigma-algebra, the *product sigma algebra* +tailored for the specific needs of tractable probabilistic inference. + +This book walks through the motivation, definition and construction of an algebra that is suitable for tractable +probabilistic reasoning. + +## Motivation + +While foundational concepts like sigma-algebras may appear abstract at first, a thorough understanding of their +properties and, specifically, product sigma-algebras, is crucial for rigorous probability theory and its applications +across various scientific disciplines, like robotics. Key motivating arguments are + +- *Foundations of probability theory*: sigma algebras are the building blocks for defining probability in a rigorous +way. By understanding them, a deeper understanding of how probabilities are assigned to events is gained. +- *Working with complex events:* In real-world scenarios, events can be intricate. Sigma algebras describe not just +simple events but also unions, intersections, and complements of these events, and hence are a powerful tool to analyze +probabilities of more complex situations. +- *Connection to advanced math:* Sigma algebras bridge the gap between set theory and advanced mathematical concepts +like measure theory and integration. Studying them opens doors to these powerful tools used in various scientific +fields. + +Especially in robotics they are important, since +- *Reasoning with uncertainty:* Robots often operate in environments with uncertainty. + Sigma algebras provide a mathematical foundation to represent uncertain events and reason about the probability of +different events happening (like sensor readings or obstacles appearing). +- *Decision-making under probability:* Many robotic tasks involve making decisions based on probabilities. By +understanding sigma algebras, algorithms can be build that consider the chance of different outcomes and choose the +action with the highest probability of success. +- *Planning and control under uncertainty:* Planning robot actions often requires considering various possibilities. +Sigma algebras allow for the creation of probabilistic models of the environment, enabling robots to plan and control +their movements while accounting for uncertainties. + +Research has shown that events that are described by independent constraints (rules) are most likely the only events +where probability estimation is tractable. {cite}`choi2020probabilistic` +Spaces that are constructed by independent constraints are called product spaces. Understanding the shape of such +events is a key competence to building (new) tractable probabilistic models. + +## Sigma Algebra + +A sigma algebra ($sigma$-algebra) is a set of sets that contains all set differences that can be constructed by +combining arbitrary subsets of the said set. Furthermore, it contains all countable unions of sets and all infinite +intersections of the set. + +````{prf:definition} Sigma Algebra +:label: def-sigma-algebra + +Let {math}`E` be a space of elementary events. Consider the powerset {math}`2^E` and let {math}`\Im \subset 2^E` be a +set of subsets of {math}`E`. Elements of {math}`\Im` are called random events. +If {math}`\Im` satisfies the following properties, it is called a sigma-algebra ({math}`\sigma`-algebra). + +```{math} +:label: eq-sigma-algebra +1. & \hspace{.5em} E \in \Im \\ +2. & \hspace{.5em} (A, B) \in \Im \Rightarrow (A - B) \in \Im \\ +3. & \hspace{.5em} (A_1, A_2, ... \in \Im) \Rightarrow \left( \bigcup_{i=1}^\mathbb{N} A_i \in \Im \wedge +\bigcap_{i=1}^\infty A_i \in \Im \right) +``` + +The tuple {math}`(E, \Im)` is called a **measurable space**. +```` + +An example of such a set of sets is the following: + +```{code-cell} ipython3 +:tags: [] +from itertools import chain, combinations + + +def powerset(iterable): + s = list(iterable) + result = list(chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))) + return [set(x) for x in result] + + +E = {"a", "b", "c"} +powerset_of_E = powerset(E) +powerset_of_E +``` + +We can see that this is a correct sigma-algebra by verifying all axioms. First, check if it contains the space of +elementary Events $E$: + +```{code-cell} ipython3 +:tags: [] + +E in powerset_of_E +``` + +Next, check if it contains all set differences: + +```{code-cell} ipython3 +:tags: [] + +for A, B in combinations(powerset_of_E, 2): + if A - B not in powerset_of_E: + print(f"Set difference {A - B} not in powerset") +``` + +Finally, check if it contains all countable unions and intersections: + +```{code-cell} ipython3 +:tags: [] + +for A, B in combinations(powerset_of_E, 2): + if A.union(B) not in powerset_of_E: + print(f"Union {A.union(B)} not in powerset") + if A.intersection(B) not in powerset_of_E: + print(f"Intersection {A.intersection(B)} not in powerset") +``` + +We have constructed a $\sigma$-algebra. This is a basic example, but it is important to understand the concept +of such a system of sets. + +The set operations union and difference can be constructed from complement and intersection. + +## Intervals +A more advanced example is the set of intervals. Intervals are a common example of a sigma-algebra that is not trivial +but yet easy to construct. + +First, I introduce the concept of simple intervals and composite intervals in {prf:ref}`def-interval`. + +````{prf:definition} Interval +:label: def-interval + +A simple interval is a subset of {math}`\mathbb{R}` denoted by + +```{math} +:label: eq-interval +(a,b) &= \{x\in \mathbb{R} \mid ancihTY58>yQhyHVAq6+lGO~MVagOauq5m9v<`6Yyea8LU7g^33d5#6JIpIaLG z-1|gCJhU3BN``QY-K@=)`@JW9M^t~b7uLWQYei|mDOJQ5UUg0~vIqbGt~C8wn@$P% z5pl~zRjG%ihlB(HjNnDEe-dDz2JixSk(`6?==a`q;3sz5kB=vYkB^Usv)VI9k21rD zJiTz9qguh+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M&5PhT=%Y7C{j)JyC3slsF1h)J!2ju6cNc?HhXJLHl25entk$v!XYOzK=(rP~Rh! z*p(T?yl4h)l~Mkkoa1>4%y{DERdSd$UE=vGXLs>#A3q)Cuz$F)ey2S&b!HYf=Mm@i z$vBfjX|diF=}~}Se`0d%u`^s!Jiz*S>KK$b5mKnTyL{tReI0e>|9%tuAFB^Xu1EqI z2*~6xoM8t-esZMcNE3x1OqyN-Lp+FtX23bZdIhv1I_L3poeEE12w+x`r3BtK?UgS_ zgjv%6!;CN9dDzM}v3-DxU~SIgW9;-IvqR%OnBm4Ejqg0G}YnQC~*J|RZ=pB5-~vu$W~ z)Un>6^zlydKLzhIZ?b;=zuG68MC1PzKM`{<{lBe>Vh5EBTCLDuB`X-584ml0{G L>8MsHTOs~GC;Fmw diff --git a/book/markdown-notebooks.md b/book/markdown-notebooks.md deleted file mode 100644 index a057a32..0000000 --- a/book/markdown-notebooks.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -jupytext: - formats: md:myst - text_representation: - extension: .md - format_name: myst - format_version: 0.13 - jupytext_version: 1.11.5 -kernelspec: - display_name: Python 3 - language: python - name: python3 ---- - -# Notebooks with MyST Markdown - -Jupyter Book also lets you write text-based notebooks using MyST Markdown. -See [the Notebooks with MyST Markdown documentation](https://jupyterbook.org/file-types/myst-notebooks.html) for more detailed instructions. -This page shows off a notebook written in MyST Markdown. - -## An example cell - -With MyST Markdown, you can define code cells with a directive like so: - -```{code-cell} -print(2 + 2) -``` - -When your book is built, the contents of any `{code-cell}` blocks will be -executed with your default Jupyter kernel, and their outputs will be displayed -in-line with the rest of your content. - -```{seealso} -Jupyter Book uses [Jupytext](https://jupytext.readthedocs.io/en/latest/) to convert text-based files to notebooks, and can support [many other text-based notebook files](https://jupyterbook.org/file-types/jupytext.html). -``` - -## Create a notebook with MyST Markdown - -MyST Markdown notebooks are defined by two things: - -1. YAML metadata that is needed to understand if / how it should convert text files to notebooks (including information about the kernel needed). - See the YAML at the top of this page for example. -2. The presence of `{code-cell}` directives, which will be executed with your book. - -That's all that is needed to get started! - -## Quickly add YAML metadata for MyST Notebooks - -If you have a markdown file and you'd like to quickly add YAML metadata to it, so that Jupyter Book will treat it as a MyST Markdown Notebook, run the following command: - -``` -jupyter-book myst init path/to/markdownfile.md -``` diff --git a/book/markdown.md b/book/markdown.md deleted file mode 100644 index faeea60..0000000 --- a/book/markdown.md +++ /dev/null @@ -1,55 +0,0 @@ -# Markdown Files - -Whether you write your book's content in Jupyter Notebooks (`.ipynb`) or -in regular markdown files (`.md`), you'll write in the same flavor of markdown -called **MyST Markdown**. -This is a simple file to help you get started and show off some syntax. - -## What is MyST? - -MyST stands for "Markedly Structured Text". It -is a slight variation on a flavor of markdown called "CommonMark" markdown, -with small syntax extensions to allow you to write **roles** and **directives** -in the Sphinx ecosystem. - -For more about MyST, see [the MyST Markdown Overview](https://jupyterbook.org/content/myst.html). - -## Sample Roles and Directives - -Roles and directives are two of the most powerful tools in Jupyter Book. They -are like functions, but written in a markup language. They both -serve a similar purpose, but **roles are written in one line**, whereas -**directives span many lines**. They both accept different kinds of inputs, -and what they do with those inputs depends on the specific role or directive -that is being called. - -Here is a "note" directive: - -```{note} -Here is a note -``` - -It will be rendered in a special box when you build your book. - -Here is an inline directive to refer to a document: {doc}`markdown-notebooks`. - - -## Citations - -You can also cite references that are stored in a `bibtex` file. For example, -the following syntax: `` {cite}`holdgraf_evidence_2014` `` will render like -this: {cite}`holdgraf_evidence_2014`. - -Moreover, you can insert a bibliography into your page with this syntax: -The `{bibliography}` directive must be used for all the `{cite}` roles to -render properly. -For example, if the references for your book are stored in `references.bib`, -then the bibliography is inserted with: - -```{bibliography} -``` - -## Learn more - -This is just a simple starter to get you started. -You can learn a lot more at [jupyterbook.org](https://jupyterbook.org). diff --git a/book/notebooks.ipynb b/book/notebooks.ipynb deleted file mode 100644 index fdb7176..0000000 --- a/book/notebooks.ipynb +++ /dev/null @@ -1,122 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Content with notebooks\n", - "\n", - "You can also create content with Jupyter Notebooks. This means that you can include\n", - "code blocks and their outputs in your book.\n", - "\n", - "## Markdown + notebooks\n", - "\n", - "As it is markdown, you can embed images, HTML, etc into your posts!\n", - "\n", - "![](https://myst-parser.readthedocs.io/en/latest/_static/logo-wide.svg)\n", - "\n", - "You can also $add_{math}$ and\n", - "\n", - "$$\n", - "math^{blocks}\n", - "$$\n", - "\n", - "or\n", - "\n", - "$$\n", - "\\begin{aligned}\n", - "\\mbox{mean} la_{tex} \\\\ \\\\\n", - "math blocks\n", - "\\end{aligned}\n", - "$$\n", - "\n", - "But make sure you \\$Escape \\$your \\$dollar signs \\$you want to keep!\n", - "\n", - "## MyST markdown\n", - "\n", - "MyST markdown works in Jupyter Notebooks as well. For more information about MyST markdown, check\n", - "out [the MyST guide in Jupyter Book](https://jupyterbook.org/content/myst.html),\n", - "or see [the MyST markdown documentation](https://myst-parser.readthedocs.io/en/latest/).\n", - "\n", - "## Code blocks and outputs\n", - "\n", - "Jupyter Book will also embed your code blocks and output in your book.\n", - "For example, here's some sample Matplotlib code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from matplotlib import rcParams, cycler\n", - "import matplotlib.pyplot as plt\n", - "import numpy as np\n", - "plt.ion()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Fixing random state for reproducibility\n", - "np.random.seed(19680801)\n", - "\n", - "N = 10\n", - "data = [np.logspace(0, 1, 100) + np.random.randn(100) + ii for ii in range(N)]\n", - "data = np.array(data).T\n", - "cmap = plt.cm.coolwarm\n", - "rcParams['axes.prop_cycle'] = cycler(color=cmap(np.linspace(0, 1, N)))\n", - "\n", - "\n", - "from matplotlib.lines import Line2D\n", - "custom_lines = [Line2D([0], [0], color=cmap(0.), lw=4),\n", - " Line2D([0], [0], color=cmap(.5), lw=4),\n", - " Line2D([0], [0], color=cmap(1.), lw=4)]\n", - "\n", - "fig, ax = plt.subplots(figsize=(10, 5))\n", - "lines = ax.plot(data)\n", - "ax.legend(custom_lines, ['Cold', 'Medium', 'Hot']);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There is a lot more that you can do with outputs (such as including interactive outputs)\n", - "with your book. For more information about this, see [the Jupyter Book documentation](https://jupyterbook.org)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.0" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/book/references.bib b/book/references.bib index 783ec6a..298a56c 100644 --- a/book/references.bib +++ b/book/references.bib @@ -1,56 +1,18 @@ --- --- -@inproceedings{holdgraf_evidence_2014, - address = {Brisbane, Australia, Australia}, - title = {Evidence for {Predictive} {Coding} in {Human} {Auditory} {Cortex}}, - booktitle = {International {Conference} on {Cognitive} {Neuroscience}}, - publisher = {Frontiers in Neuroscience}, - author = {Holdgraf, Christopher Ramsay and de Heer, Wendy and Pasley, Brian N. and Knight, Robert T.}, - year = {2014} +@article{choi2020probabilistic, + title={Probabilistic circuits: A unifying framework for tractable probabilistic models}, + author={Choi, Y and Vergari, Antonio and Van den Broeck, Guy}, + journal={UCLA. URL: http://starai. cs. ucla. edu/papers/ProbCirc20. pdf}, + pages={6}, + year={2020} } -@article{holdgraf_rapid_2016, - title = {Rapid tuning shifts in human auditory cortex enhance speech intelligibility}, - volume = {7}, - issn = {2041-1723}, - url = {http://www.nature.com/doifinder/10.1038/ncomms13654}, - doi = {10.1038/ncomms13654}, - number = {May}, - journal = {Nature Communications}, - author = {Holdgraf, Christopher Ramsay and de Heer, Wendy and Pasley, Brian N. and Rieger, Jochem W. and Crone, Nathan and Lin, Jack J. and Knight, Robert T. and Theunissen, Frédéric E.}, - year = {2016}, - pages = {13654}, - file = {Holdgraf et al. - 2016 - Rapid tuning shifts in human auditory cortex enhance speech intelligibility.pdf:C\:\\Users\\chold\\Zotero\\storage\\MDQP3JWE\\Holdgraf et al. - 2016 - Rapid tuning shifts in human auditory cortex enhance speech intelligibility.pdf:application/pdf} +@article{kolmogorov1933grundbegriffe, + title={Grundbegriffe der Wahrscheinlichkeitrechnung (Ergebnisse Der Mathematik). Translated by Morrison, N}, + author={Kolmogorov, A}, + journal={Foundations of probability}, + year={1933} } -@inproceedings{holdgraf_portable_2017, - title = {Portable learning environments for hands-on computational instruction using container-and cloud-based technology to teach data science}, - volume = {Part F1287}, - isbn = {978-1-4503-5272-7}, - doi = {10.1145/3093338.3093370}, - abstract = {© 2017 ACM. There is an increasing interest in learning outside of the traditional classroom setting. This is especially true for topics covering computational tools and data science, as both are challenging to incorporate in the standard curriculum. These atypical learning environments offer new opportunities for teaching, particularly when it comes to combining conceptual knowledge with hands-on experience/expertise with methods and skills. Advances in cloud computing and containerized environments provide an attractive opportunity to improve the effciency and ease with which students can learn. This manuscript details recent advances towards using commonly-Available cloud computing services and advanced cyberinfrastructure support for improving the learning experience in bootcamp-style events. We cover the benets (and challenges) of using a server hosted remotely instead of relying on student laptops, discuss the technology that was used in order to make this possible, and give suggestions for how others could implement and improve upon this model for pedagogy and reproducibility.}, - booktitle = {{ACM} {International} {Conference} {Proceeding} {Series}}, - author = {Holdgraf, Christopher Ramsay and Culich, A. and Rokem, A. and Deniz, F. and Alegro, M. and Ushizima, D.}, - year = {2017}, - keywords = {Teaching, Bootcamps, Cloud computing, Data science, Docker, Pedagogy} -} - -@article{holdgraf_encoding_2017, - title = {Encoding and decoding models in cognitive electrophysiology}, - volume = {11}, - issn = {16625137}, - doi = {10.3389/fnsys.2017.00061}, - abstract = {© 2017 Holdgraf, Rieger, Micheli, Martin, Knight and Theunissen. Cognitive neuroscience has seen rapid growth in the size and complexity of data recorded from the human brain as well as in the computational tools available to analyze this data. This data explosion has resulted in an increased use of multivariate, model-based methods for asking neuroscience questions, allowing scientists to investigate multiple hypotheses with a single dataset, to use complex, time-varying stimuli, and to study the human brain under more naturalistic conditions. These tools come in the form of “Encoding” models, in which stimulus features are used to model brain activity, and “Decoding” models, in which neural features are used to generated a stimulus output. Here we review the current state of encoding and decoding models in cognitive electrophysiology and provide a practical guide toward conducting experiments and analyses in this emerging field. Our examples focus on using linear models in the study of human language and audition. We show how to calculate auditory receptive fields from natural sounds as well as how to decode neural recordings to predict speech. The paper aims to be a useful tutorial to these approaches, and a practical introduction to using machine learning and applied statistics to build models of neural activity. The data analytic approaches we discuss may also be applied to other sensory modalities, motor systems, and cognitive systems, and we cover some examples in these areas. In addition, a collection of Jupyter notebooks is publicly available as a complement to the material covered in this paper, providing code examples and tutorials for predictive modeling in python. The aimis to provide a practical understanding of predictivemodeling of human brain data and to propose best-practices in conducting these analyses.}, - journal = {Frontiers in Systems Neuroscience}, - author = {Holdgraf, Christopher Ramsay and Rieger, J.W. and Micheli, C. and Martin, S. and Knight, R.T. and Theunissen, F.E.}, - year = {2017}, - keywords = {Decoding models, Encoding models, Electrocorticography (ECoG), Electrophysiology/evoked potentials, Machine learning applied to neuroscience, Natural stimuli, Predictive modeling, Tutorials} -} - -@book{ruby, - title = {The Ruby Programming Language}, - author = {Flanagan, David and Matsumoto, Yukihiro}, - year = {2008}, - publisher = {O'Reilly Media} -} diff --git a/book/requirements.txt b/book/requirements.txt index 7e821e4..459f343 100644 --- a/book/requirements.txt +++ b/book/requirements.txt @@ -1,3 +1,5 @@ jupyter-book matplotlib numpy +ghp-import +sphinx-proof \ No newline at end of file diff --git a/src/random_events/interval.py b/src/random_events/interval.py index 413d106..cc99c2a 100644 --- a/src/random_events/interval.py +++ b/src/random_events/interval.py @@ -163,7 +163,7 @@ def center(self) -> float: """ :return: The center point of the interval """ - return ((self.lower + self.upper) / 2) + self.lower + return (self.lower + self.upper) / 2 class Interval(sigma_algebra.AbstractCompositeSet): diff --git a/src/random_events/sigma_algebra.py b/src/random_events/sigma_algebra.py index d2a5cc8..49a47d0 100644 --- a/src/random_events/sigma_algebra.py +++ b/src/random_events/sigma_algebra.py @@ -303,7 +303,7 @@ def to_string(self): """ if self.is_empty(): return EMPTY_SET_SYMBOL - return "{" + " u ".join([simple_set.to_string() for simple_set in self.simple_sets]) + "}" + return " u ".join([simple_set.to_string() for simple_set in self.simple_sets]) def __str__(self): return self.to_string()