phdu.stats.test package¶
Submodules¶
phdu.stats.test.permutation module¶
2-sample permutation test, with/without pairing (including block pairing), for the difference and the ratio.
Only implemented for the mean and median. Check functions starting with underscore to implement other statistics. Will be refined in the future.
- phdu.stats.test.permutation.permutation_test_2sample_not_paired_mean(X1, X2, ratio=False, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Permutation test for the differences or ratio of the means (non-paired).
- Attrs:
- alternative: - greater: H0: mu_1 - mu_2 < observed, H1: mu_1 - mu_2 >= observed
less: H0: mu_1 - mu_2 > observed, H1: mu_1 - mu_2 <= observed
two-sided: H0: mu_1 - mu_2 = observed, H1: mu_1 - mu_2 != observed
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_not_paired_median(X1, X2, ratio=False, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Non-paired permutation test for the median.
- Attrs:
- alternative:
greater: H0: me_1 / me_2 < observed, H1: me_1 / me_2 >= observed
- ratio - less: H0: me_1 / me_2 > observed, H1: me_1 / me_2 <= observed
two-sided: H0: me_1 / me_2 = observed, H1: me_1 / me_2 != observed
greater: H0: me_1 - me_2 < observed, H1: me_1 - me_2 >= observed
- not ratio - less: H0: me_1 - me_2 > observed, H1: me_1 - me_2 <= observed
two-sided: H0: me_1 - me_2 = observed, H1: me_1 - me_2 != observed
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_paired_block_mean(X, Y, ratio=False, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Permutation test for the mean for paired blocks. Permutations occur only between blocks: X1(block i) <-> X2(block i). Numba won’t compile. This is a sketch such that the only thing to implement is stat_func.
- Attrs:
X, Y: ragged arrays or tuples. Each element is an array containing the results for a block. alternative:
greater: H0: mu_1 / mu_2 < observed, H1: mu_1 / mu_2 >= observed
- ratio - less: H0: mu_1 / mu_2 > observed, H1: mu_1 / mu_2 <= observed
two-sided: H0: mu_1 / mu_2 = observed, H1: mu_1 / mu_2 != observed
greater: H0: mu_1 - mu_2 < observed, H1: mu_1 - mu_2 >= observed
- not ratio - less: H0: mu_1 - mu_2 > observed, H1: mu_1 - mu_2 <= observed
two-sided: H0: mu_1 - mu_2 = observed, H1: mu_1 - mu_2 != observed
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_paired_block_median(X, Y, ratio=False, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Permutation test for the mean for paired blocks. Permutations occur only between blocks: X1(block i) <-> X2(block i). Numba won’t compile. This is a sketch such that the only thing to implement is stat_func.
- Attrs:
X, Y: ragged arrays or tuples. Each element is an array containing the results for a block. alternative:
greater: H0: mu_1 / mu_2 < observed, H1: mu_1 / mu_2 >= observed
- ratio - less: H0: mu_1 / mu_2 > observed, H1: mu_1 / mu_2 <= observed
two-sided: H0: mu_1 / mu_2 = observed, H1: mu_1 / mu_2 != observed
greater: H0: mu_1 - mu_2 < observed, H1: mu_1 - mu_2 >= observed
- not ratio - less: H0: mu_1 - mu_2 > observed, H1: mu_1 - mu_2 <= observed
two-sided: H0: mu_1 - mu_2 = observed, H1: mu_1 - mu_2 != observed
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_paired_diffmean(X1, X2, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Paired permutation test optimized for the mean of the differences. about 2x faster than the default _permutation_test_2sample_paired with stat_func = np.mean. Coincides with the test for the differences in means. (Not as the median) Attrs:
- alternative: - greater: H0: mu(X1-X2) < <X1-X2>_sample, H1: mu(X1-X2) >= <X1-X2>_sample
less: H0: mu(X1-X2) > <X1-X2>_sample, H1: mu(X1-X2) <= <X1-X2>_sample
two-sided: H0: mu(X1-X2) = <X1-X2>_sample, H1: mu(X1-X2) != <X1-X2>_sample
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_paired_diffmedian(X1, X2, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Paired permutation test optimized for the median of the differences. about 2x faster than the default _permutation_test_2sample_paired with stat_func = np.mean. NOTE: Does not coincide with the test for the differences in medians.
- Attrs:
- alternative: - greater: H0: me(X1-X2) < observed, H1: me(X1-X2) >= observed
less: H0: me(X1-X2) > observed, H1: me(X1-X2) <= observed
two-sided: H0: me(X1-X2) = observed, H1: me(X1-X2) != observed.
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_paired_mean(X1, X2, ratio=False, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Paired permutation test for the mean
- Attrs:
- alternative:
greater: H0: mu_1 / mu_2 < observed, H1: mu_1 / mu_2 >= observed
- ratio - less: H0: mu_1 / mu_2 > observed, H1: mu_1 / mu_2 <= observed
two-sided: H0: mu_1 / mu_2 = observed, H1: mu_1 / mu_2 != observed
greater: H0: mu_1 - mu_2 < observed, H1: mu_1 - mu_2 >= observed
- not ratio - less: H0: mu_1 - mu_2 > observed, H1: mu_1 - mu_2 <= observed
two-sided: H0: mu_1 - mu_2 = observed, H1: mu_1 - mu_2 != observed
Returns: p-value
- phdu.stats.test.permutation.permutation_test_2sample_paired_median(X1, X2, ratio=False, N=999999, alternative='two-sided', tolerance=1.5e-08, seed=0)[source]¶
Paired permutation test for the median.
- Attrs:
- alternative:
greater: H0: me_1 / me_2 < observed, H1: me_1 / me_2 >= observed
- ratio - less: H0: me_1 / me_2 > observed, H1: me_1 / me_2 <= observed
two-sided: H0: me_1 / me_2 = observed, H1: me_1 / me_2 != observed
greater: H0: me_1 - me_2 < observed, H1: me_1 - me_2 >= observed
- not ratio - less: H0: me_1 - me_2 > observed, H1: me_1 - me_2 <= observed
two-sided: H0: me_1 - me_2 = observed, H1: me_1 - me_2 != observed
Returns: p-value