Skip to main content

A Power Analysis Toolkit for Python

Project description

PyStatPower

build test lint PyPI - Version Python Version from PEP 621 TOML GitHub License PyPI - Status PyPI - Downloads

Code style: black codecov

PyStatPower 是一个专注于统计领域功效分析的开源的 Python 库。

主要功能:样本量和检验效能的计算,以及给定参数下估算所需效应量大小。

详细文档

[!WARNING] 本项目处于 alpha 阶段,文档尚未完成。

安装

pip install pystatpower

示例

计算样本量

单组样本率检验

from pystatpower.models import one_proportion

result = one_proportion.solve_for_sample_size(
    alpha=0.05, power=0.80, nullproportion=0.80, proportion=0.95, alternative="two_sided", test_type="exact_test"
)
print(result)

输出:

Size(41.59499160228066)

两独立样本率差异性检验

from pystatpower.models import two_proportion

result = two_proportion.solve_for_sample_size(
    alpha=0.05,
    power=0.80,
    treatment_proportion=0.95,
    reference_proportion=0.80,
    alternative="two_sided",
    test_type="z_test_pooled",
)
print(result)

输出:

(Size(75.11862332120842), Size(75.11862332120842))

计算检验效能

from pystatpower.models.two_proportion import solve_for_power, GroupAllocation

result = solve_for_power(
    alpha=0.05,
    treatment_proportion=0.95,
    reference_proportion=0.80,
    alternative="two_sided",
    test_type="z_test_pooled",
    group_allocation=GroupAllocation(
        size_of_treatment=100,
        size_of_reference=50,
    ),
)
print(result)

输出:

Power(0.7865318578853373)

鸣谢

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

pystatpower-0.0.2.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

pystatpower-0.0.2-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file pystatpower-0.0.2.tar.gz.

File metadata

  • Download URL: pystatpower-0.0.2.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pystatpower-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1fae3c84ee8ad6bf9f1fadea174e7f703661dd8d3105ba8ff3bdb29f01259290
MD5 808750482257d9b633a408e7613aa427
BLAKE2b-256 48da2d637d6ddf66e9dbfe6586187bf9ce5ee12eb639e119448d462cd1e66f18

See more details on using hashes here.

File details

Details for the file pystatpower-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pystatpower-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pystatpower-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c4c70b69b229e05cbf7725afa604db5ada7f89e3890673e545ea01ae33fbb174
MD5 1aaf486bccccfba78c3bb2177bb9b6a1
BLAKE2b-256 35869cf5e66a74d46ed8e0c65869028a40779ed14c563eb722b90f886e4281ee

See more details on using hashes here.

Supported by

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