bundles / scipy latest / scipy / stats / _bws_test / bws_test
function
scipy.stats._bws_test:bws_test
source: /scipy/stats/_bws_test.py :63
Signature
def bws_test ( x , y , * , alternative = two-sided , method = None ) Summary
Perform the Baumgartner-Weiss-Schindler test on two independent samples.
Extended Summary
The Baumgartner-Weiss-Schindler (BWS) test is a nonparametric test of the null hypothesis that the distribution underlying sample x is the same as the distribution underlying sample y. Unlike the Kolmogorov-Smirnov, Wilcoxon, and Cramer-Von Mises tests, the BWS test weights the integral by the variance of the difference in cumulative distribution functions (CDFs), emphasizing the tails of the distributions, which increases the power of the test in many applications.
Parameters
x, y: array-like1-d arrays of samples.
alternative: {'two-sided', 'less', 'greater'}, optionalDefines the alternative hypothesis. Default is 'two-sided'. Let F(u) and G(u) be the cumulative distribution functions of the distributions underlying
xandy, respectively. Then the following alternative hypotheses are available:'two-sided': the distributions are not equal, i.e. F(u) ≠ G(u) for at least one u.
'less': the distribution underlying
xis stochastically less than the distribution underlyingy, i.e. F(u) >= G(u) for all u.'greater': the distribution underlying
xis stochastically greater than the distribution underlyingy, i.e. F(u) <= G(u) for all u.
Under a more restrictive set of assumptions, the alternative hypotheses can be expressed in terms of the locations of the distributions; see [2] section 5.1.
method: PermutationMethod, optionalConfigures the method used to compute the p-value. The default is the default PermutationMethod object.
Returns
res: PermutationTestResult: An object with attributes:statistic: floatThe observed test statistic of the data.
pvalue: floatThe p-value for the given alternative.
null_distribution: ndarrayThe values of the test statistic generated under the null hypothesis.
Notes
When alternative=='two-sided', the statistic is defined by the equations given in [1] Section 2. This statistic is not appropriate for one-sided alternatives; in that case, the statistic is the negative of that given by the equations in [1] Section 2. Consequently, when the distribution of the first sample is stochastically greater than that of the second sample, the statistic will tend to be positive.
Array API Standard Support
bws_test has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ⛔ ⛔ JAX ⛔ ⛔ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
We follow the example of table 3 in [1]_: Fourteen children were divided randomly into two groups. Their ranks at performing a specific tests are as follows.import numpy as np x = [1, 2, 3, 4, 6, 7, 8] y = [5, 9, 10, 11, 12, 13, 14]✓
from scipy.stats import bws_test res = bws_test(x, y) print(res.statistic)✓
print(res.pvalue)
✓See also
- scipy.stats.mannwhitneyu
- scipy.stats.ttest_ind
- scipy.stats.wilcoxon
Aliases
-
scipy.stats.bws_test