Pragmastat: Pragmatic Statistical Toolkit
Project description
Python
Install from PyPI:
pip install pragmastat==5.0.0
Source code: https://github.com/AndreyAkinshin/pragmastat/tree/v5.0.0/py
Pragmastat on PyPI: https://pypi.org/project/pragmastat/
Demo
from pragmastat import (
Rng,
median,
center,
spread,
rel_spread,
shift,
ratio,
avg_spread,
disparity,
pairwise_margin,
shift_bounds,
)
from pragmastat.distributions import Additive, Exp, Multiplic, Power, Uniform
def main():
# --- Randomization ---
rng = Rng(1729)
print(rng.uniform()) # 0.3943034703296536
print(rng.uniform()) # 0.5730893757071377
rng = Rng("experiment-1")
print(rng.uniform()) # 0.9535207726895857
rng = Rng(1729)
print(rng.sample([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 3)) # [6, 8, 9]
rng = Rng(1729)
print(rng.shuffle([1, 2, 3, 4, 5])) # [4, 2, 3, 5, 1]
# --- Distribution Sampling ---
rng = Rng(1729)
dist = Uniform(0, 10)
print(dist.sample(rng)) # 3.9430347032965365
rng = Rng(1729)
dist = Additive(0, 1)
print(dist.sample(rng)) # -1.222932972163442
rng = Rng(1729)
dist = Exp(1)
print(dist.sample(rng)) # 0.5013761944646019
rng = Rng(1729)
dist = Power(1, 2)
print(dist.sample(rng)) # 1.284909255071668
rng = Rng(1729)
dist = Multiplic(0, 1)
print(dist.sample(rng)) # 0.2943655336550937
# --- Single-Sample Statistics ---
x = [0, 2, 4, 6, 8]
print(median(x)) # 4
print(center(x)) # 4
print(spread(x)) # 4
print(spread([v + 10 for v in x])) # 4
print(spread([v * 2 for v in x])) # 8
print(rel_spread(x)) # 1
# --- Two-Sample Comparison ---
x = [0, 3, 6, 9, 12]
y = [0, 2, 4, 6, 8]
print(shift(x, y)) # 2
print(shift(y, x)) # -2
print(avg_spread(x, y)) # 5
print(disparity(x, y)) # 0.4
print(disparity(y, x)) # -0.4
x = [1, 2, 4, 8, 16]
y = [2, 4, 8, 16, 32]
print(ratio(x, y)) # 0.5
# --- Confidence Bounds ---
x = list(range(1, 31))
y = list(range(21, 51))
print(pairwise_margin(30, 30, 1e-4)) # 390
print(shift(x, y)) # -20
bounds = shift_bounds(x, y, 1e-4) # [-30, -10]
print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")
if __name__ == "__main__":
main()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pragmastat-5.0.0.tar.gz
(29.3 kB
view details)
File details
Details for the file pragmastat-5.0.0.tar.gz.
File metadata
- Download URL: pragmastat-5.0.0.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c5274294c08c5ce564a0f98b35db3295d0277a28c16dd62fa9ea734e642a489
|
|
| MD5 |
ec99472664add5826de248ba778cfcc8
|
|
| BLAKE2b-256 |
e3d7db9a6b54e324575d0bef163a248bef1b8fcc08ffd2f78cfb6b830ee8472d
|
Provenance
The following attestation bundles were made for pragmastat-5.0.0.tar.gz:
Publisher:
publish.yml on AndreyAkinshin/pragmastat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pragmastat-5.0.0.tar.gz -
Subject digest:
9c5274294c08c5ce564a0f98b35db3295d0277a28c16dd62fa9ea734e642a489 - Sigstore transparency entry: 871249033
- Sigstore integration time:
-
Permalink:
AndreyAkinshin/pragmastat@d8371cd47be7e36d5f9a7ce9a4982b47d0447ec0 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/AndreyAkinshin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8371cd47be7e36d5f9a7ce9a4982b47d0447ec0 -
Trigger Event:
push
-
Statement type: