A tool for doing hypothesis testing
Project description
Description
A package to run hypothesis testing for one and two samples.
One Sample Hypothesis Testing
from hypothesis_testing_tool.compute_stats.one_sample_statistics import OneSampleTest
Let's see an example of how you can use the OneSampleTest
class.
data = [1, 2, 5, 8, 10]
null_population_mean = 3.5
t_test = OneSampleTest(
data = [1, 2, 5, 8, 10],
null_population_mean = 3.5
).t_test_results
print(f"p-value: {t_test.pvalue:.2f}")
print(f"t-statistic: {t_test.statistic:.2f}")
p-value: 0.38
t-statistic: 0.99
The default is with alternative = "two-sided", but that can change to a one tail test.
t_test_less = OneSampleTest(
data = [1, 2, 5, 8, 10],
null_population_mean = 3.5,
alternative = "less"
)
t_test_greater = OneSampleTest(
data = [1, 2, 5, 8, 10],
null_population_mean = 3.5,
alternative = "greater"
)
You can also compute the confidence interval (default = 95%) for the mean, using the calculate_ci
method.
The calculate_ci
method takes an optional argument alpha
to adjust to 99% CI (alpha = 0.01) or any other.
confidence_interval = OneSampleTest(
data = [1, 2, 5, 8, 10],
null_population_mean = 3.5
).calculate_ci()
confidence_interval
{'lower_bound': 0.43938833539220123,
'point_estimate': 5.2,
'upper_bound': 9.9606116646078,
'null_population_mean': 3.5}
Finally, you can create a plot with the CI and save it to a local path.
from hypothesis_testing_tool.presentation.create_plots import create_one_sample_hypothesis_plot
ci_dict = OneSampleTest(
data = [1, 2, 5, 8, 10],
null_population_mean = 3.5
).calculate_ci()
ci_plot = create_one_sample_hypothesis_plot("artifacts/one_sample_plot.png", ci_dict)
In the plot above the 95% confidence interval includes 3.5, so we do not reject the null hypothesis.
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
Built Distribution
Close
Hashes for hypothesis_testing_tool-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2449e68340941d87550b48b7d6c0935c169234aaa990ad8b18929422d59f6f90 |
|
MD5 | 91f352edc66fa605656c180e5bbe9478 |
|
BLAKE2b-256 | d6fadc971f78b0f6e9b48b1fd03453f9d2f4a8677f52f4f8cfc96b727b81790a |
Close
Hashes for hypothesis_testing_tool-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 590ecb668f8b1b0561eef15ffecd42546d8690b228cc6b171537121df2cef986 |
|
MD5 | eaaa389dca533cc8161a2a12a0171840 |
|
BLAKE2b-256 | ec5ff9174d87c3ba45d5616538852503867cec0cec49e83c1998583b4f89522d |