Pragmastat: Pragmatic Statistical Toolkit
Project description
Python
Install from PyPI:
pip install pragmastat==9.0.0
Source code: https://github.com/AndreyAkinshin/pragmastat/tree/v9.0.0/py
Pragmastat on PyPI: https://pypi.org/project/pragmastat/
Demo
from pragmastat import (
Rng,
center,
spread,
rel_spread,
shift,
ratio,
avg_spread,
disparity,
center_bounds,
shift_bounds,
ratio_bounds,
)
from pragmastat.distributions import Additive, Exp, Multiplic, Power, Uniform
def main():
# --- Randomization ---
rng = Rng("demo-uniform")
print(rng.uniform()) # 0.2640554428629759
print(rng.uniform()) # 0.9348534835582796
rng = Rng("demo-sample")
print(rng.sample([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 3)) # [3, 8, 9]
rng = Rng("demo-shuffle")
print(rng.shuffle([1, 2, 3, 4, 5])) # [4, 2, 3, 5, 1]
rng = Rng("demo-resample")
print(rng.resample([1, 2, 3, 4, 5], 7)) # [5, 1, 1, 3, 3, 4, 5]
# --- Distribution Sampling ---
rng = Rng("demo-dist-uniform")
dist = Uniform(0, 10)
print(dist.sample(rng)) # 6.54043657816832
rng = Rng("demo-dist-additive")
dist = Additive(0, 1)
print(dist.sample(rng)) # 0.17410448679568188
rng = Rng("demo-dist-exp")
dist = Exp(1)
print(dist.sample(rng)) # 0.6589065267276553
rng = Rng("demo-dist-power")
dist = Power(1, 2)
print(dist.sample(rng)) # 1.023677535537084
rng = Rng("demo-dist-multiplic")
dist = Multiplic(0, 1)
print(dist.sample(rng)) # 1.1273244602673853
# --- Single-Sample Statistics ---
x = [1, 3, 5, 7, 9]
print(center(x)) # 5
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)) # 0.8
# --- 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
print(ratio(y, x)) # 2
# --- One-Sample Bounds ---
x = list(range(1, 11))
print(center(x)) # 5.5
bounds = center_bounds(x, 0.05) # Bounds(lower=3.5, upper=7.5)
print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")
# --- Two-Sample Bounds ---
x = list(range(1, 31))
y = list(range(21, 51))
print(shift(x, y)) # -20
bounds = shift_bounds(x, y, 1e-4) # Bounds(lower=-30, upper=-10)
print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")
x = [1, 2, 3, 4, 5]
y = [2, 3, 4, 5, 6]
bounds = ratio_bounds(x, y, 0.05) # Bounds(lower=0.333..., upper=1.5)
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-9.0.0.tar.gz
(36.1 kB
view details)
File details
Details for the file pragmastat-9.0.0.tar.gz.
File metadata
- Download URL: pragmastat-9.0.0.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d07a4905846b3363a66f4e212f0a5af12fff4daa043ca3b13f4957d8eccc4e8
|
|
| MD5 |
ceaba3a43188b0c77cee74af5232bf00
|
|
| BLAKE2b-256 |
492346feaf062afc35a6ac3737431f4591361c79eacd0df70f42515926d3fef2
|
Provenance
The following attestation bundles were made for pragmastat-9.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-9.0.0.tar.gz -
Subject digest:
1d07a4905846b3363a66f4e212f0a5af12fff4daa043ca3b13f4957d8eccc4e8 - Sigstore transparency entry: 954386430
- Sigstore integration time:
-
Permalink:
AndreyAkinshin/pragmastat@daa11318b129f5f8e111b7e00a99ec16ea2cff03 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AndreyAkinshin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@daa11318b129f5f8e111b7e00a99ec16ea2cff03 -
Trigger Event:
workflow_dispatch
-
Statement type: