pystatpower


Namepystatpower JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryA Power Analysis Toolkit for Python
upload_time2024-09-26 18:46:59
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseGPL-3.0
keywords power power-analysis sample-size mathematics statistics
VCS
bugtrack_url
requirements scipy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyStatPower

[![build](https://img.shields.io/github/actions/workflow/status/PyStatPower/PyStatPower/release.yml?branch=main&label=build)](https://github.com/PyStatPower/PyStatPower/actions/workflows/release.yml?query=branch:main)
[![test](https://img.shields.io/github/actions/workflow/status/PyStatPower/PyStatPower/check.yml?branch=main&label=test)](https://github.com/PyStatPower/PyStatPower/actions/workflows/check.yml?query=branch:main)
[![lint](https://img.shields.io/github/actions/workflow/status/PyStatPower/PyStatPower/black.yml?branch=main&label=lint)](https://github.com/PyStatPower/PyStatPower/actions/workflows/black.yml?query=branch:main)
[![PyPI - Version](https://img.shields.io/pypi/v/pystatpower)](https://badge.fury.io/py/pystatpower)
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FPyStatPower%2FPyStatPower%2Fmain%2Fpyproject.toml)
![GitHub License](https://img.shields.io/github/license/PyStatPower/PyStatPower)
![PyPI - Status](https://img.shields.io/pypi/status/PyStatPower)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pystatpower)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![codecov](https://codecov.io/gh/PyStatPower/PyStatPower/graph/badge.svg?token=P9UWC8Q4P6)](https://codecov.io/gh/PyStatPower/PyStatPower)

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

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

[详细文档](https://pystatpower.github.io/PyStatPower-Docs)

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

## 安装

```cmd
pip install pystatpower
```

## 示例

### 计算样本量

#### 单组样本率检验

```python
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)
```

输出:

```python
Size(41.59499160228066)
```

#### 两独立样本率差异性检验

```python
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)
```

输出:

```python
(Size(75.11862332120842), Size(75.11862332120842))
```

### 计算检验效能

```python
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)
```

输出:

```python
Power(0.7865318578853373)
```

## 鸣谢

- [scipy](https://github.com/scipy/scipy)
- [pingouin](https://github.com/raphaelvallat/pingouin)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pystatpower",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "power, power-analysis, sample-size, mathematics, statistics",
    "author": null,
    "author_email": "Snoopy1866 <openpower2024@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/48/da/2d637d6ddf66e9dbfe6586187bf9ce5ee12eb639e119448d462cd1e66f18/pystatpower-0.0.2.tar.gz",
    "platform": null,
    "description": "# PyStatPower\n\n[![build](https://img.shields.io/github/actions/workflow/status/PyStatPower/PyStatPower/release.yml?branch=main&label=build)](https://github.com/PyStatPower/PyStatPower/actions/workflows/release.yml?query=branch:main)\n[![test](https://img.shields.io/github/actions/workflow/status/PyStatPower/PyStatPower/check.yml?branch=main&label=test)](https://github.com/PyStatPower/PyStatPower/actions/workflows/check.yml?query=branch:main)\n[![lint](https://img.shields.io/github/actions/workflow/status/PyStatPower/PyStatPower/black.yml?branch=main&label=lint)](https://github.com/PyStatPower/PyStatPower/actions/workflows/black.yml?query=branch:main)\n[![PyPI - Version](https://img.shields.io/pypi/v/pystatpower)](https://badge.fury.io/py/pystatpower)\n![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FPyStatPower%2FPyStatPower%2Fmain%2Fpyproject.toml)\n![GitHub License](https://img.shields.io/github/license/PyStatPower/PyStatPower)\n![PyPI - Status](https://img.shields.io/pypi/status/PyStatPower)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pystatpower)\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![codecov](https://codecov.io/gh/PyStatPower/PyStatPower/graph/badge.svg?token=P9UWC8Q4P6)](https://codecov.io/gh/PyStatPower/PyStatPower)\n\nPyStatPower \u662f\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u7edf\u8ba1\u9886\u57df\u529f\u6548\u5206\u6790\u7684\u5f00\u6e90\u7684 Python \u5e93\u3002\n\n\u4e3b\u8981\u529f\u80fd\uff1a\u6837\u672c\u91cf\u548c\u68c0\u9a8c\u6548\u80fd\u7684\u8ba1\u7b97\uff0c\u4ee5\u53ca\u7ed9\u5b9a\u53c2\u6570\u4e0b\u4f30\u7b97\u6240\u9700\u6548\u5e94\u91cf\u5927\u5c0f\u3002\n\n[\u8be6\u7ec6\u6587\u6863](https://pystatpower.github.io/PyStatPower-Docs)\n\n> [!WARNING]\n> \u672c\u9879\u76ee\u5904\u4e8e alpha \u9636\u6bb5\uff0c\u6587\u6863\u5c1a\u672a\u5b8c\u6210\u3002\n\n## \u5b89\u88c5\n\n```cmd\npip install pystatpower\n```\n\n## \u793a\u4f8b\n\n### \u8ba1\u7b97\u6837\u672c\u91cf\n\n#### \u5355\u7ec4\u6837\u672c\u7387\u68c0\u9a8c\n\n```python\nfrom pystatpower.models import one_proportion\n\nresult = one_proportion.solve_for_sample_size(\n    alpha=0.05, power=0.80, nullproportion=0.80, proportion=0.95, alternative=\"two_sided\", test_type=\"exact_test\"\n)\nprint(result)\n```\n\n\u8f93\u51fa\uff1a\n\n```python\nSize(41.59499160228066)\n```\n\n#### \u4e24\u72ec\u7acb\u6837\u672c\u7387\u5dee\u5f02\u6027\u68c0\u9a8c\n\n```python\nfrom pystatpower.models import two_proportion\n\nresult = two_proportion.solve_for_sample_size(\n    alpha=0.05,\n    power=0.80,\n    treatment_proportion=0.95,\n    reference_proportion=0.80,\n    alternative=\"two_sided\",\n    test_type=\"z_test_pooled\",\n)\nprint(result)\n```\n\n\u8f93\u51fa\uff1a\n\n```python\n(Size(75.11862332120842), Size(75.11862332120842))\n```\n\n### \u8ba1\u7b97\u68c0\u9a8c\u6548\u80fd\n\n```python\nfrom pystatpower.models.two_proportion import solve_for_power, GroupAllocation\n\nresult = solve_for_power(\n    alpha=0.05,\n    treatment_proportion=0.95,\n    reference_proportion=0.80,\n    alternative=\"two_sided\",\n    test_type=\"z_test_pooled\",\n    group_allocation=GroupAllocation(\n        size_of_treatment=100,\n        size_of_reference=50,\n    ),\n)\nprint(result)\n```\n\n\u8f93\u51fa\uff1a\n\n```python\nPower(0.7865318578853373)\n```\n\n## \u9e23\u8c22\n\n- [scipy](https://github.com/scipy/scipy)\n- [pingouin](https://github.com/raphaelvallat/pingouin)\n",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "A Power Analysis Toolkit for Python",
    "version": "0.0.2",
    "project_urls": {
        "Changelog": "https://github.com/PyStatPower/PyStatPower/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/PyStatPower/PyStatPower/blob/main/README.md",
        "Homepage": "https://github.com/PyStatPower/PyStatPower",
        "Issues": "https://github.com/PyStatPower/PyStatPower/issues",
        "Repository": "https://github.com/PyStatPower/PyStatPower.git"
    },
    "split_keywords": [
        "power",
        " power-analysis",
        " sample-size",
        " mathematics",
        " statistics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35869cf5e66a74d46ed8e0c65869028a40779ed14c563eb722b90f886e4281ee",
                "md5": "1aaf486bccccfba78c3bb2177bb9b6a1",
                "sha256": "c4c70b69b229e05cbf7725afa604db5ada7f89e3890673e545ea01ae33fbb174"
            },
            "downloads": -1,
            "filename": "pystatpower-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1aaf486bccccfba78c3bb2177bb9b6a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 25350,
            "upload_time": "2024-09-26T18:46:58",
            "upload_time_iso_8601": "2024-09-26T18:46:58.303960Z",
            "url": "https://files.pythonhosted.org/packages/35/86/9cf5e66a74d46ed8e0c65869028a40779ed14c563eb722b90f886e4281ee/pystatpower-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48da2d637d6ddf66e9dbfe6586187bf9ce5ee12eb639e119448d462cd1e66f18",
                "md5": "808750482257d9b633a408e7613aa427",
                "sha256": "1fae3c84ee8ad6bf9f1fadea174e7f703661dd8d3105ba8ff3bdb29f01259290"
            },
            "downloads": -1,
            "filename": "pystatpower-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "808750482257d9b633a408e7613aa427",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 27472,
            "upload_time": "2024-09-26T18:46:59",
            "upload_time_iso_8601": "2024-09-26T18:46:59.632527Z",
            "url": "https://files.pythonhosted.org/packages/48/da/2d637d6ddf66e9dbfe6586187bf9ce5ee12eb639e119448d462cd1e66f18/pystatpower-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 18:46:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PyStatPower",
    "github_project": "PyStatPower",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.12.0"
                ]
            ]
        }
    ],
    "lcname": "pystatpower"
}
        
Elapsed time: 0.49411s