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/ - the library code.
See the next section for the library's structure and main entities.
Examples/ - code examples using the library.
The Jupyter Notebook TeaserNotebook.ipynb walks through multiple examples in a tutorial format. You can read it in this repo. To run the code, either:
-
Install
EfProband Jupyter Notebook (docs), then runjupyter notebookin the Examples directory. -
Run the exported Python version TeaserNotebook.py.
Docs/ - documentation for the library.
You can see the full documentation here.
Tests/ - tests for the library.
Before running the tests, you should install pytest with pip install pytest (see pytest docs). 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 theSpacefunction. You can also directly use the classesListSpacefor a discrete space,IntervalSpacefor a continuous space, andProductSpacefor 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 theStatefunction. You can also directly use the classDiscStatefor a discrete state, andContStatefor 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 thePredicatefunction, and there are alsoDiscPredicateandContPredicateclasses. -
channels (
channel_class.py) represent probabilistic computations between spaces. As with states, the default way to create a channel is to use theChannelfunction, and there are alsoDiscChannelandContChannelclasses.
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.
Metadata
Release files for efprob 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| efprob-1.0.0.tar.gz | 87.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| efprob-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 181.7 kB
Release files / efprob-1.0.0.tar.gz
| Download URL | efprob-1.0.0.tar.gz |
|---|---|
| Size | 87.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4882c9eccb8900aaa988a69a20fa49b8ed3040787ea01c257b7052ee4ad66bfd
|
|
BLAKE2b-256 checksum How to use checksums |
eea3700017ea7b75e5efca8293c629bdaaa2fd0437dce9d3ccc03137bfdba326
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / efprob-1.0.0-py3-none-any.whl
| Download URL | efprob-1.0.0-py3-none-any.whl |
|---|---|
| Size | 94.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1c9e8ce701733f8de52c4745d5ede9bdd597ae2887ed3ee70a46e5a162d2468
|
|
BLAKE2b-256 checksum How to use checksums |
f79c668ca972c04374f582e9e8c266e3d7fb6eb1ef72fc6a03e17589a11683e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|