Skip to main content

Pragmastat: Pragmatic Statistical Toolkit

Project description

Python

Install from PyPI:

pip install pragmastat==4.0.2

Source code: https://github.com/AndreyAkinshin/pragmastat/tree/v4.0.2/py

Pragmastat on PyPI: https://pypi.org/project/pragmastat/

Demo

from pragmastat import (
    center,
    spread,
    rel_spread,
    shift,
    ratio,
    avg_spread,
    disparity,
    pairwise_margin,
    shift_bounds,
)


def main():
    x = [0, 2, 4, 6, 8]
    print(center(x))  # 4
    print(center([v + 10 for v in x]))  # 14
    print(center([v * 3 for v in x]))  # 12

    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
    print(rel_spread([v * 5 for v in x]))  # 1

    y = [10, 12, 14, 16, 18]
    print(shift(x, y))  # -10
    print(shift(x, x))  # 0
    print(shift([v + 7 for v in x], [v + 3 for v in y]))  # -6
    print(shift([v * 2 for v in x], [v * 2 for v in y]))  # -20
    print(shift(y, x))  # 10

    x = [1, 2, 4, 8, 16]
    y = [2, 4, 8, 16, 32]
    print(ratio(x, y))  # 0.5
    print(ratio(x, x))  # 1
    print(ratio([v * 2 for v in x], [v * 5 for v in y]))  # 0.2

    x = [0, 3, 6, 9, 12]
    y = [0, 2, 4, 6, 8]
    print(spread(x))  # 6
    print(spread(y))  # 4

    print(avg_spread(x, y))  # 5
    print(avg_spread(x, x))  # 6
    print(avg_spread([v * 2 for v in x], [v * 3 for v in x]))  # 15
    print(avg_spread(y, x))  # 5
    print(avg_spread([v * 2 for v in x], [v * 2 for v in y]))  # 10

    print(shift(x, y))  # 2
    print(avg_spread(x, y))  # 5

    print(disparity(x, y))  # 0.4
    print(disparity([v + 5 for v in x], [v + 5 for v in y]))  # 0.4
    print(disparity([v * 2 for v in x], [v * 2 for v in y]))  # 0.4
    print(disparity(y, x))  # -0.4

    x = list(range(1, 31))
    y = list(range(21, 51))

    print(pairwise_margin(30, 30, 1e-6))  # 276
    print(pairwise_margin(30, 30, 1e-5))  # 328
    print(pairwise_margin(30, 30, 1e-4))  # 390
    print(pairwise_margin(30, 30, 1e-3))  # 464

    print(shift(x, y))  # -20

    bounds = shift_bounds(x, y, 1e-6)  # [-33, -7]
    print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")
    bounds = shift_bounds(x, y, 1e-5)  # [-32, -8]
    print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")
    bounds = shift_bounds(x, y, 1e-4)  # [-30, -10]
    print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")
    bounds = shift_bounds(x, y, 1e-3)  # [-28, -12]
    print(f"Bounds(lower={bounds.lower}, upper={bounds.upper})")


if __name__ == "__main__":
    main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pragmastat-4.0.2.tar.gz (22.4 kB view details)

Uploaded Source

File details

Details for the file pragmastat-4.0.2.tar.gz.

File metadata

  • Download URL: pragmastat-4.0.2.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pragmastat-4.0.2.tar.gz
Algorithm Hash digest
SHA256 8dfa48aaeab130913618c4e6a500dee891c22a8ea31c802d5aaadf8f2352c8a4
MD5 b1ebea4e8b9060187a4067d7a66269c9
BLAKE2b-256 7ee9b64c3dd13c3faa740752f82c8683c33ec6a9c20304a62be6f75a3368321f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pragmastat-4.0.2.tar.gz:

Publisher: publish.yml on AndreyAkinshin/pragmastat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page