Skip to main content

prspace

Probability spaces with the same syntax in Python and R: Pr[X == 0] = 0.25.

Alpha. The API may change between 0.x releases.

import math
from prspace import PrSpace, Event

n_samples = math.comb(19, 10)
Pr = PrSpace()
S_B = Event(support="count")  # 0, 1, 2, ...

for B in (100, 1000):
    Pr[S_B == 0] = math.prod(1 - k / n_samples for k in range(B))
    print("Pr[S_B >= 1] =", Pr[S_B >= 1])  # derived: S_B is a count

print(Pr)
# PrSpace with 1 probability:
#   Pr[S_B == 0] = 0.004397413
  • Complements are derived: after Pr[X == 0] = 0.25, Pr[X != 0] and Pr[~(X == 0)] are 0.75.
  • Event(support=...) takes "real" (default), "integer", "count", or a list like [1, 2, 3] or ["H", "T"], and anything the rules of probability then pin down is derived.
  • PrSpace(check="warn" | "error" | "off", derive=True): assignments that contradict earlier ones warn or raise InconsistentProbabilityError, saying which values would have been consistent.
  • Reading a value that can't be determined raises UndefinedProbabilityError (a KeyError) with the known bounds in .lower and .upper.
  • Event names are inferred from the variable they're bound to, or pass Event("name").

The R package has the same syntax. See the repository for both.

Metadata

Release files for prspace 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prspace 0.2.0
File Size Uploaded Provenance
prspace-0.2.0.tar.gz 9.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for prspace 0.2.0
File Interpreter ABI Platform
prspace-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / prspace-0.2.0.tar.gz

Download URL prspace-0.2.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
178be868dcb77388c219fe875e73ebca3df7328a04647ed9e637b774e4a3f278
BLAKE2b-256 checksum
How to use checksums
edad3545abc894bc9f9276e1cd88efc34583ada1857bf30b8b0d3a13d7812561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / prspace-0.2.0-py3-none-any.whl

Download URL prspace-0.2.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afac40a95db0a4a0c3beb7977d17e0a8370d5eac4263a834d7df0186766d2268
BLAKE2b-256 checksum
How to use checksums
8cdbdf682f828d2d627ad5d2b4ef201dd3ab8775ad77994f7053b60a5515b478
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Security for prspace 0.2.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for prspace-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page