mds_2025_helper_functions.htv ============================= .. py:module:: mds_2025_helper_functions.htv Functions --------- .. autoapisummary:: mds_2025_helper_functions.htv.htv Module Contents --------------- .. py:function:: htv(test_output, test_type='z', alpha=0.05, tail='two-tailed') Visualize Type I (α) and Type II (β) errors in hypothesis testing. :param test_output: Dictionary containing hypothesis test parameters: - 'mu0': Mean under the null hypothesis (H0) - 'mu1': Mean under the alternative hypothesis (H1) - 'sigma': Standard deviation (for z or t tests) - 'sample_size': Sample size (for z and t tests) - 'df1': Degrees of freedom 1 (for F tests, optional) - 'df2': Degrees of freedom 2 (for F tests, optional) - 'df': Degrees of freedom (for t and chi-squared tests, optional) :type test_output: dict :param test_type: Type of test ('z', 't', 'chi2', 'anova'). :type test_type: str :param alpha: Significance level (Type I error rate). :type alpha: float :param tail: One-tailed or two-tailed test ("one-tailed" or "two-tailed"). :type tail: str :returns: (fig, ax) Matplotlib figure and axes objects. :rtype: tuple .. rubric:: Example >>> import numpy as np >>> from mds_2025_helper_functions.htv import htv >>> >>> # Example: Visualizing a two-tailed z-test >>> test_params = { ... 'mu0': 100, # Null hypothesis mean ... 'mu1': 105, # Alternative mean ... 'sigma': 15, # Standard deviation ... 'sample_size': 30 # Sample size ... } >>> fig, ax = htv(test_params, test_type="z", alpha=0.05, tail="two-tailed") >>> plt.show() # This will plot the null and alternative hypothesis distributions with # shaded regions for Type I and Type II errors, and mark the critical values. >>> # Example: One-tailed t-test with degrees of freedom >>> test_params_t = { ... 'mu0': 0, ... 'mu1': 1.5, ... 'sigma': 1, ... 'sample_size': 25 ... } >>> fig, ax = htv(test_params_t, test_type="t", alpha=0.01, tail="one-tailed") >>> plt.show() # This will plot a one-tailed t-test diagram with appropriate critical regions.