Skip to main content
`Ctrl`+`K`

# scipy.special.boxcox

scipy.special.boxcox(x, lmbda, out=None) = <ufunc 'boxcox'>

  Compute the Box-Cox transformation.

  The Box-Cox transformation is:

      y = (x**lmbda - 1) / lmbda  if lmbda != 0
          log(x)                  if lmbda == 0

  Returns nan if `x < 0`. Returns -inf if `x == 0` and `lmbda < 0`.

  Parameters:
    x array_like

      Data to be transformed.

    lmbda array_like

      Power parameter of the Box-Cox transform.

    out ndarray, optional

      Optional output array for the function values

  Returns:
    y scalar or ndarray

      Transformed data.

  Notes

  Added in version 0.14.0.

  Array API Standard Support

  `boxcox` 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 | ⚠️ no JIT | ⛔
  Dask | ✅ | n/a

  > See Support for the array API standard for more information.

  Examples

      >>> from scipy.special import boxcox
      >>> boxcox([1, 4, 10], 2.5)
      array([   0.        ,   12.4       ,  126.09110641])
      >>> boxcox(2, [0, 1, 2])
      array([ 0.69314718,  1.        ,  1.5       ])