qbitnum
Quantum‐Inspired Numeric Data Type for Classical Python
qbitnum provides a QBitNum class that simulates qubit‑like superposition for integer/float values, letting you perform probabilistic arithmetic in pure Python.
Features
- Store distributions of possible values with associated probabilities
- Support
+,-,*,//(and extendable) operations over superposed states - Post‑operation “collapse” in three modes:
- mean: expected value
- max: most likely value
- sample: random draw by probability
Installation
pip install qbitnum
from qbitnum import QBitNum
# Create superposed values
q1 = QBitNum([(1, 0.5), (2, 0.5)])
q2 = QBitNum([(3, 0.7), (4, 0.3)])
# Add them
q3 = q1 + q2
print(q3)
# QBitNum({4: 0.35, 5: 0.5, 6: 0.15})
# Collapse to a single value:
print(q3.collapse('mean')) # 4.8
print(q3.collapse('max')) # 5
print(q3.collapse('sample')) # 4 or 5 or 6 (random)
class QBitNum:
def __init__(self, states: List[Tuple[Number, float]]):
"""
states: list of (value, probability), probabilities need not sum to 1.
"""
def __add__(self, other: QBitNum) -> QBitNum: # likewise -, *, //
def collapse(self, mode: str = 'mean') -> Number
"""
mode in {'mean', 'max', 'sample'}
"""
Metadata
Release files for qbitnum 0.1.3
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 |
|---|---|---|---|---|
| qbitnum-0.1.3.tar.gz | 3.1 kB | Without provenance | Details for qbitnum-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qbitnum-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for qbitnum-0.1.3-py3-none-any.whl |
Total release size: 6.9 kB
Release files / qbitnum-0.1.3.tar.gz
| Download URL | qbitnum-0.1.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbac7383b33aa4abf8e95baca337916db00b0bb2fe17c9588dd248084afaceb9
|
|
BLAKE2b-256 checksum How to use checksums |
3147108853c4a04d8644214d59222555514cc8c1bc5991b99adc5e37aa71ecc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Release files / qbitnum-0.1.3-py3-none-any.whl
| Download URL | qbitnum-0.1.3-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb692090ccf21f4f1777088a17164bd8dea56a4edbe6f45e37af812dc8dea89f
|
|
BLAKE2b-256 checksum How to use checksums |
76cdfdf116a418267fa7eaf10a4518c4fdb40911d97f28d319694eca36371025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Security for qbitnum 0.1.3
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.