Repository: scipy/scipy
File: scipy/stats/_morestats.py (Python)

Code before:

    Determine and plot the optimal ``lmbda`` to transform ``x`` and plot it in
    the same plot:

    >>> _, maxlog = stats.boxcox(x)
    >>> ax.axvline(maxlog, color='r')

    >>> plt.show()

    """
    return _normplot('boxcox', x, la, lb, plot, N)


@xp_capabilities(np_only=True)
def yeojohnson(x, lmbda=None, *, nan_policy='propagate'):
    r"""Return a dataset transformed by a Yeo-Johnson power transformation.

    Parameters
    ----------
    x : ndarray
        Input array.  Should be 1-dimensional.
    lmbda : float, optional
        If ``lmbda`` is ``None``, find the lambda that maximizes the
        log-likelihood function and return it as the second output argument.
        Otherwise the transformation is done for the given value.
    nan_policy : {‘propagate’, ‘omit’, ‘raise’}
        Defines how to handle NaNs in `x`.

        - ``propagate``: if a NaN is present, all outputs will contain NaNs.
        - ``omit``: NaNs will be omitted when calculating the optimal `maxlog`;
           NaNs in `x` will remain NaNs in the transformed data.
        - ``raise``: if a NaN is present, a ``ValueError`` will be raised.

    Returns
    -------
    yeojohnson: ndarray
        Yeo-Johnson power transformed array.
    maxlog : float, optional
        If the `lmbda` parameter is None, the second returned argument is
        the lambda that maximizes the log-likelihood function.

    See Also
    --------
    probplot, yeojohnson_normplot, yeojohnson_normmax, yeojohnson_llf, boxcox

    Notes
    -----
    The Yeo-Johnson transform is given by:

    .. math::


Review comment (suggestion):
```suggestion
    nan_policy : {'propagate', 'omit', 'raise'}
```

Code after:

    Determine and plot the optimal ``lmbda`` to transform ``x`` and plot it in
    the same plot:

    >>> _, maxlog = stats.boxcox(x)
    >>> ax.axvline(maxlog, color='r')

    >>> plt.show()

    """
    return _normplot('boxcox', x, la, lb, plot, N)


@xp_capabilities(np_only=True)
def yeojohnson(x, lmbda=None, *, nan_policy='propagate'):
    r"""Return a dataset transformed by a Yeo-Johnson power transformation.

    Parameters
    ----------
    x : ndarray
        Input array.  Should be 1-dimensional.
    lmbda : float, optional
        If ``lmbda`` is ``None``, find the lambda that maximizes the
        log-likelihood function and return it as the second output argument.
        Otherwise the transformation is done for the given value.
    nan_policy : {'propagate', 'omit', 'raise'}
        Defines how to handle NaNs in `x`.

        - ``propagate``: if a NaN is present, all outputs will contain NaNs.
        - ``omit``: NaNs will be omitted when calculating the optimal `maxlog`;
           NaNs in `x` will remain NaNs in the transformed data.
        - ``raise``: if a NaN is present, a ``ValueError`` will be raised.

    Returns
    -------
    yeojohnson: ndarray
        Yeo-Johnson power transformed array.
    maxlog : float, optional
        If the `lmbda` parameter is None, the second returned argument is
        the lambda that maximizes the log-likelihood function.

    See Also
    --------
    probplot, yeojohnson_normplot, yeojohnson_normmax, yeojohnson_llf, boxcox

    Notes
    -----
    The Yeo-Johnson transform is given by:

    .. math::