{ } Raw JSON

bundles / scipy 1.18.0 / scipy / stats / _stats_py / obrientransform

function

scipy.stats._stats_py:obrientransform

source: /scipy/stats/_stats_py.py:2509

Signature

def obrientransform(*samples, nan_policy = propagate)

Summary

Compute the O'Brien transform on input data (any number of arrays).

Extended Summary

Used to test for homogeneity of variance prior to running one-way stats. Each array in *samples is one level of a factor. Significant results of f_oneway on the transformed data suggest that the variances of the underlying distributions are unequal. See Maxwell and Delaney [1], p.112.

Parameters

*samples : array_like

Any number of arrays.

nan_policy : {'propagate', 'omit', 'raise'}

Defines how to handle input NaNs.

  • propagate: if a NaN is present in a sample, all elements of the transformed sample will be NaN.

  • omit: NaNs will be omitted when computing reducing statistics for the transform, but NaNs in the sample will remain NaNs in the transformed sample.

  • raise: if a NaN is present, a ValueError will be raised.

Returns

obrientransform : tuple of arrays

Transformed arrays for use in ANOVA.

Raises

: ValueError

If the mean of the transformed data is not equal to the original variance, indicating a lack of convergence in the O'Brien transform.

Notes

Array API Standard Support

obrientransform 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-arrayapi for more information.

Examples

We'll test the following data sets for differences in their variance.
x = [10, 11, 13, 9, 7, 12, 12, 9, 10]
y = [13, 21, 5, 10, 8, 14, 10, 12, 7, 15]
✓
Apply the O'Brien transform to the data.
from scipy.stats import obrientransform
tx, ty = obrientransform(x, y)
✓
Use `scipy.stats.f_oneway` to apply a one-way ANOVA test to the transformed data.
from scipy.stats import f_oneway
F, p = f_oneway(tx, ty)
✓
p
✗
np.float64(0.13141394770403342)
If we require that ``p < 0.05`` for significance, we cannot conclude that the variances are different.

Aliases

  • scipy.stats.obrientransform

Referenced by