Skip to main content

A Python package for easy Hypothesis Tests

Project description

Easy Hypothesis Test

A Python package for easy Hypothesis Tests

Authors

Installation

Install my-project with npm

  pip install easy-ht

Requirements

  • scipy
  • statsmodels
  • jupyter-lab (optional)

Usage/Examples

For examples, check the folder examples, containing some Jupyter Notebooks to get started.

Documentation

The easy_ht package contains a basic class, called HypothesisTest.

HypothesisTest

A class used to calculate Hypothesis Tests, including both one sample and two sample tests.

Methods

  • check_normality(self,alpha = 0.05) Check if samples are follow a normal distribution, using the Shapiro test.
  • check_correlation(self, alpha = 0.05) Check if samples are correlated. It can be used only in two samples tests.
  • check_randomness(self, alpha = 0.05, cutoff='mean') Check if the sample has been built in a random way.
  • compare_means(self, value = None, alpha = 0.05, n = 50) In one sample test, compare the sample to an expected value. In two samples test, compare the mean of the two samples.
  • compare_distributions(self, alpha = 0.05, cdf = None, args=(), freq = False) In one sample test, compare the sample to a distribution. In two samples tests, compare the distributions of the two samples.

init(self,x, y = None, verbose = False, alpha = 0.05):

Parameters

  • x : array_like the (first) sample to be analysed

  • y : array_like, optional the second sample to be analysed

  • verbose : bool, optional, default = False enable debug messages

  • alpha : float, optional, default = 0.05** the significance level

check_normality(self,alpha = 0.05)

Check if samples follow a normal distribution, according to the Shapiro test. In case of two samples, check if both the samples follow a normal distribution.

Parameters

  • alpha : float, optional, default = 0.05 the significance level

Returns

  • bool

True, if the sample of both the samples follow a normal distribution. False, otherwise.

check_correlation(self, alpha = 0.05)

Check if samples are correlated. If samples follow a normal distribution, the Pearson Correlation Coefficient is used, otherwise the Spearman Rank Correlation is used. This is a simple test, which does not return the statistics. Correlation is calculated only on the basis of p-value.

Parameters

  • alpha : float, optional, default = 0.05 the significance level

Returns

  • bool or None

True, if samples are correlated, False otherwise. None is returned in the case that the second sample has not been set.

check_randomness(self, alpha = 0.05, cutoff='mean'):

Check if the sample has been generated in a random way.

Parameters

  • alpha : float, optional, default = 0.05 the significance level

  • cutoff : {'mean', 'median'} or number, optional, default = 'mean' the cutoff to split the data into large and small values.

Returns

  • bool

True, if the sample has been generated in a random way. False, otherwise.

compare_means(self, value = None, alpha = 0.05, n = 50)

Compare the sample mean to a theoretical value, or compare samples means. If samples follow a normal distribution, the t-test is used if the number of samples is less than n. The z-test, otherwise. If the samples are not normal, the Wilcoxon test is used.

Parameters

  • value : float, optional the theoretical value to be compared, in case of one sample

  • alpha : float, optional, default = 0.05 the significance level

  • n : int, optional, default = 50 a number used to discriminate if a sample is small or big. if sample size <= n, t-test is used, otherwise z-test is used.

Returns

  • bool True, if the sample means is similar to the theoretical value or the two samples means are similar. False, otherwise.

compare_distributions(self, alpha = 0.05, cdf = None, args=(), freq = False):

Compare the sample distribution to a given cdf (cumulative distribution function), if one sample is provided. The Kolmogorov-Smirnov Test is used. Compare the samples distribution, if two samples are provided. In this case, the Chi Square test is used.

Parameters

  • alpha : float, optional, default = 0.05 the significance level

  • cdf : str, array_like or callable if array_like, it is an array of observations of random variables, and the two-sample test is performed. If a callable, that callable is used to calculate the cdf. If a string, it should be the name of a distribution in scipy.stats, which will be used as the cdf function.

  • args : tuple, sequence, optional distribution parameters, used cdf is string or callables.

  • freq : bool, optional, default = False specify if the sample is an array of frequencies. This is used to discriminate if using the Chi Square Test or Kolmogorov-Smirnov Test.

Returns

  • bool or None True, if the sample follows the specified distribution or the two samples follow the same distribution. False, otherwise. If error, return None.

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

easy-ht-0.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

easy_ht-0.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file easy-ht-0.0.1.tar.gz.

File metadata

  • Download URL: easy-ht-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.1

File hashes

Hashes for easy-ht-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9258dcd4e6bbb6f1ed8d74960a569749de47acf944cbf0cf983c99ff5c70c513
MD5 dc8c77145a6a64c852307d0493a69311
BLAKE2b-256 55cc85e83f8d8fb202c802132312e284c56b8c3dc6bf57db39ad200382bc52aa

See more details on using hashes here.

File details

Details for the file easy_ht-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: easy_ht-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.1

File hashes

Hashes for easy_ht-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6c048bc8451d93b574cab1d7c44bc0e19b180378df0d3524c7932880ca02875
MD5 bb0211cd63e442144cf3056c3a6743fa
BLAKE2b-256 b54eda8fa0043c39d5c485c4bd0e237d6a02cf48ccf5521a0ef62f25272565c4

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