probs
Probability is a concept that many introductory Computer Science courses teach because of its frequent application in algorithms, data structures, and other mathematical fields. While numerous libraries for expressing probabilities exist (e.g. scipy, statistics, etc), the majority of them focus primarily on the application of these concepts rather than showcasing the mechanics of the mathematical theory.
The goal of this project is to leverage Python's built-in language features to expose an intuitive and expandable API for simple probabilitic expressions.
Usage
pip install probs
Examples
from probs import *
# define a normally-distributed random variable with
# mean = 0, variance = 1
X = Normal()
assert E(X) == 0
assert Var(X) == 1 / 12
assert X.pdf(0.5) == 2
# combine multiple random variables
u, v = Uniform(), Uniform()
assert E(u) == 1 / 2
assert Var(u) == 1 / 12
assert (u * v).pdf(0.5) == 39.0169
assert (1 * v).pdf(0.5) == 1
assert E(u + 1) == 1.5
assert E(u + v) == 1
assert E(u - v) == 0
assert Var(u + v) == 1 / 6
Documentation
Contributing
All issues and pull requests are much appreciated! To build the project:
- probs is actively developed using the lastest version of Python.
- First, be sure to run
pre-commit install. - To run all tests and use auto-formatting tools, use
pre-commit run. - To only run unit tests, run
pytest.
- First, be sure to run
TODO List
-
Use ApproxFloat across all operations.
-
Dataclasses are iffy, because:
-
Need to set super().init() in order to get the parent class's fields.
-
Need to set eq=False on all RandomVariables.
-
Need to set repr=False in order to get the parent's repr method.
-
However, clearer init function provided, other operators potentially builtin.
-
repr can be inherited without a rewrite
-
inheritance works so long as every parent is also a dataclass.
-
super short init syntax
-
-
Figure out how to merge pmf and custom pmf functions.
Metadata
Release files for probs 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| probs-0.0.6.tar.gz | 17.6 kB | Without provenance | Details for probs-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| probs-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for probs-0.0.6-py3-none-any.whl |
Total release size: 43.8 kB
Release files / probs-0.0.6.tar.gz
| Download URL | probs-0.0.6.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e656aefd2dbf95f121f4ac1cc832ab696a518220e4146667bdcd21118e89ee96
|
|
BLAKE2b-256 checksum How to use checksums |
28fb9af7cf91c07e219f335a9fdc156d7fb80e298b763c3101081f702332f153
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.2
|
Release files / probs-0.0.6-py3-none-any.whl
| Download URL | probs-0.0.6-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcfc26b96e558cc87a7460bb16b7df87d3bd121ff8f4a998603c763adbb840e9
|
|
BLAKE2b-256 checksum How to use checksums |
942b6e31f44a8b1b67ac8bd25c641b36d18e45be5fd8f33c2ab117c67925ce67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.2
|
Security for probs 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.