Metadata-Version: 2.4
Name: efprob
Version: 1.0.0
Summary: Channel-based probability calculations
Author-email: Bart Jacobs <bart@cs.ru.nl>, Mark Széles <mark.szeles@ru.nl>, Arvid Bonten <arvid.bonten@ru.nl>, Codrin Iftode <codrin.iftode@ru.nl>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://effectus.pages.science.ru.nl/EfProb/
Project-URL: Documentation, https://effectus.pages.science.ru.nl/EfProb/
Keywords: probability,channels,statistics
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: sympy
Requires-Dist: matplotlib
Requires-Dist: gmpy2
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: furo; extra == "docs"
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: sphinx; extra == "dev"
Requires-Dist: furo; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# Installation

Install the library from PyPI with ```pip install efprob```.

# Quick start

Here is a simple example to get you started:

```
from efprob import *
state     = State("1/4|H> + 3/4|T>")  # A probability distribution over heads and tails
predicate = Predicate("2<H| + 1<T|")  # Assign value 2 to heads, and value 1 to tails
expected  = state >= predicate        # Compute expected value: 5/4
print(expected)
```

See the Examples section further down for more examples.

# Repo Structure

### [efprob/](./efprob/) - the library code.

See the next section for the library's structure and main entities.

### [Examples/](./Examples/) - code examples using the library.

The Jupyter Notebook [TeaserNotebook.ipynb](./Examples/TeaserNotebook.ipynb) walks through multiple examples in a tutorial format. You can read it in this repo. To run the code, either:

1) Install `EfProb` and Jupyter Notebook ([docs](https://jupyter.org/install)), then run `jupyter notebook` in the Examples directory.

2) Run the exported Python version [TeaserNotebook.py](./Examples/TeaserNotebook.py).

### [Docs/](./Docs/) - documentation for the library.

You can see the full documentation [here](https://effectus.pages.science.ru.nl/EfProb/).

### [Tests/](./Tests/) - tests for the library. 

Before running the tests, you should install `pytest` with `pip install pytest` (see [pytest docs](https://docs.pytest.org/en/stable/getting-started.html#get-started)). When you are in the root directory, you can run the tests with `pytest -v Tests`.

# Library Structure

```
├── space_class.py       # Classes for discrete and continuous probability spaces 
├── state_class.py       # Classes for discrete and continuous states
├── predicate_class.py   # Classes for discrete and continuous predicates
├── channel_class.py     # Classes for discrete and continuous channels
├── mask_class.py        # Collapse states to fewer dimensions
├── predef
│   ├── spaces.py        # Predefined spaces
│   ├── states.py        # Predefined states
│   ├── predicates.py    # Predefined predicates
│   ├── channels.py      # Predefined channels
│   └── masks.py         # Predefined masks
├── functor.py           # A fragile implementation of functoriality
├── config.py            # Global flags
├── plot.py              # Functions for plotting states
├── parse.py             # A parser for all the entities in the library
├── function.py          # Tools for entities that represent functions
└── utils.py             # General helper functions
```

The library has four main kinds of entities:

- spaces (```space_class.py```) represent probability spaces. The default way to create a space is to use the ```Space``` function. You can also directly use the classes ```ListSpace``` for a discrete space, ```IntervalSpace``` for a continuous space, and ```ProductSpace``` for the cartesian product of multiple discrete or continuous spaces.

- states (```state_class.py```) represent multisets or probability distributions over a space. The default way to create a state is to use the ```State``` function. You can also directly use the class  ```DiscState``` for a discrete state, and ```ContState``` for a continuous state.

- predicates (```predicate_class.py```) represent real-valued functions on a space. As with states, the default way to create a predicate is to use the ```Predicate``` function, and there are also ```DiscPredicate``` and ```ContPredicate``` classes.

- channels (```channel_class.py```) represent probabilistic computations between spaces. As with states, the default way to create a channel is to use the ```Channel``` function, and there are also ```DiscChannel``` and ```ContChannel``` classes.

The library provides predefined entities of each kind, in the ```predef/``` directory. For example, the predefined states are in the file ```predef/states.py```. The line ```from efprob import *``` imports all predefined entities.
