A Power Analysis Toolkit for Python
Project description
PyStatPower
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 *
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.ForPower(
GroupAllocationOption.SIZE_OF_TREATMENT | GroupAllocationOption.SIZE_OF_REFERENCE,
size_of_treatment=100,
size_of_reference=50,
),
)
print(result)
输出:
Power(0.7865318578853373)
鸣谢
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
pystatpower-0.0.1.tar.gz
(26.2 kB
view details)
Built Distribution
File details
Details for the file pystatpower-0.0.1.tar.gz
.
File metadata
- Download URL: pystatpower-0.0.1.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a6b660b5c353e88196e652e9aaa34f5a6711456154afaccb0615e45881a48c5 |
|
MD5 | 2d5ca1f6be17b688e09bd0aabed14502 |
|
BLAKE2b-256 | faabbbb8c6cf5e64aef9d4804d7ccba870d8582fa2001c88dea47122317a8e9a |
File details
Details for the file pystatpower-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pystatpower-0.0.1-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1e4156064eae4f63f5959217a003bc9fcb823d92648ce884af355a75341fd00 |
|
MD5 | 3900874cd599b996fd28675bd8656240 |
|
BLAKE2b-256 | 008618c3a5900c19d4e65321e19314355c48d68eb07460e129bf252fc02c94b4 |