Skip to main content

This package allows you to perform power analysis computations

Project description

power-analysis 💪🔍

power-analysis is a Python package for performing power analysis and calculating sample sizes for statistical models. The package provides classes for defining statistical models, performing power analysis, and calculating sample sizes for two-sample t-tests.

Installation 📥

You can install the power-analysis package using pip:

pip install power-analysis

Usage 🧑‍💻

To use the power-analysis package, you first need to define a statistical model using a Python function that takes a sample size as input and returns the estimated effect size of the model. For example:

def my_model(n):
    # define your model here
    effect_size = ...
    return effect_size

You can then create a Model object using this function:

from power_analysis import Model

model = Model(my_model)

You can perform a power analysis for this model using the PowerAnalysis class:

from power_analysis import PowerAnalysis

power_analysis = PowerAnalysis(model, n=100, alpha=0.05, power=0.8, effect_size=0.5, iterations=1000)
results = power_analysis.results()

This will calculate the minimum detectable effect and sample size required to achieve a power of 0.8 for the given model, starting with an initial sample size of 100.

You can also calculate the sample size required for a two-sample t-test using the TTestSampleSize class:

from power_analysis import TTestSampleSize

mean_diff = 1.5
sd = 2.0
alpha = 0.05
power = 0.8

sample_size = TTestSampleSize(mean_diff, sd, alpha, power, n=None)
n = sample_size.result()

This will calculate the sample size required to achieve a power of 0.8 for a two-sample t-test with a difference in means of 1.5, a standard deviation of 2.0, and a significance level of 0.05.

Contributing 🤝

Contributions to power-analysis are welcome! If you find a bug or would like to suggest a new feature, please open an issue on GitHub.

License 📜

power-analysis is licensed under the MIT license. See LICENSE for more information.

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

power_analysis-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

power_analysis-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file power_analysis-0.1.0.tar.gz.

File metadata

  • Download URL: power_analysis-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10

File hashes

Hashes for power_analysis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aeed2283483fc3c72539774eae9c781bf6f163f462362127967511420878da7f
MD5 fe274928820e0cbdb0ce0be96dcaa6d6
BLAKE2b-256 60c3e4f52b52ac0af436b4ecceea5c91d6a88e09b0fc8fe1457798c1b8af9861

See more details on using hashes here.

File details

Details for the file power_analysis-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: power_analysis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10

File hashes

Hashes for power_analysis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1cc790bc6ef92f31c3f0f34c403ef46dc4c6d308363ec8800ef2cc3551cbe1d
MD5 92d82b69527c2013cd614c48f5feb257
BLAKE2b-256 d02781aa61784d133596ca45c95ede65cc2209f48da1d617bdb07152845eca51

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