Skip to main content

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.

Metadata

Release files for easy-ht 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-ht 0.0.1
File Size Uploaded Provenance
easy-ht-0.0.1.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-ht 0.0.1
File Interpreter ABI Platform
easy_ht-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / easy-ht-0.0.1.tar.gz

Download URL easy-ht-0.0.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9258dcd4e6bbb6f1ed8d74960a569749de47acf944cbf0cf983c99ff5c70c513
BLAKE2b-256 checksum
How to use checksums
55cc85e83f8d8fb202c802132312e284c56b8c3dc6bf57db39ad200382bc52aa
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / easy_ht-0.0.1-py3-none-any.whl

Download URL easy_ht-0.0.1-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6c048bc8451d93b574cab1d7c44bc0e19b180378df0d3524c7932880ca02875
BLAKE2b-256 checksum
How to use checksums
b54eda8fa0043c39d5c485c4bd0e237d6a02cf48ccf5521a0ef62f25272565c4
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for easy-ht 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page