o
    X۷i                     @  s   d dl mZ d dlmZ dZejdddeddZd	Zejd
ddeddZdZ	ejddde	ddZ
dZejdddeddZdZejdddeddZdZejdddeddZd Zejd!dd"ed#dZd$S )%    )annotations)_corez^
template <typename T>
static __device__ T logit(T x) {
    x /= 1 - x;
    return log(x);
}


cupy_logit))e->dzout0 = logit(double(in0))f->fd->dzout0 = logit(in0)zLogit function.

    Args:
        x (cupy.ndarray): input data

    Returns:
        cupy.ndarray: values of logit(x)

    .. seealso:: :data:`scipy.special.logit`

    )preambledoczY
template <typename T>
static __device__ T expit(T x) {
    return 1 / (1 + exp(-x));
}


cupy_expit))r   zout0 = expit(double(in0))r   r   zout0 = expit(in0)a  Logistic sigmoid function (expit).

    Args:
        x (cupy.ndarray): input data (must be real)

    Returns:
        cupy.ndarray: values of expit(x)

    .. seealso:: :data:`scipy.special.expit`

    .. note::
        expit is the inverse of logit.

    z
template <typename T>
static __device__ T log_expit(T x)
{
    if (x < 0.0) {
        return x - log1p(exp(x));
    } else {
        return -log1p(exp(-x));
    }
}

cupy_log_expit))r   zout0 = log_expit(double(in0))r   r   zout0 = log_expit(in0)a  Logarithm of the logistic sigmoid function.

    Args:
        x (cupy.ndarray): input data (must be real)

    Returns:
        cupy.ndarray: values of log(expit(x))

    .. seealso:: :data:`scipy.special.log_expit`

    .. note::
        The function is mathematically equivalent to ``log(expit(x))``, but
        is formulated to avoid loss of precision for inputs with large
        (positive or negative) magnitude.
    a1  
static __device__ double boxcox(double x, double lmbda) {
    // if lmbda << 1 and log(x) < 1.0, the lmbda*log(x) product can lose
    // precision, furthermore, expm1(x) == x for x < eps.
    // For doubles, the range of log is -744.44 to +709.78, with eps being
    // the smallest value produced.  This range means that we will have
    // abs(lmbda)*log(x) < eps whenever abs(lmbda) <= eps/-log(min double)
    // which is ~2.98e-19.
    if (fabs(lmbda) < 1e-19) {
        return log(x);
    } else {
        return expm1(lmbda * log(x)) / lmbda;
    }
}

cupy_boxcox)zee->fzff->fzdd->dz"out0 = out0_type(boxcox(in0, in1))zCompute the Box-Cox transformation.

    Args:
        x (cupy.ndarray): input data (must be real)

    Returns:
        cupy.ndarray: values of boxcox(x)

    .. seealso:: :data:`scipy.special.boxcox`

    a  
static __device__ double boxcox1p(double x, double lmbda) {
    // The argument given above in boxcox applies here with the modification
    // that the smallest value produced by log1p is the minimum representable
    // value, rather than eps.  The second condition here prevents underflow
    // when log1p(x) is < eps.
    double lgx = log1p(x);
    if ((fabs(lmbda) < 1e-19)
        || ((fabs(lgx) < 1e-289) && (fabs(lmbda) < 1e273))) {
        return lgx;
    } else {
        return expm1(lmbda * lgx) / lmbda;
    }
}

cupy_boxcox1pz$out0 = out0_type(boxcox1p(in0, in1))zCompute the Box-Cox transformation op 1 + `x`.

    Args:
        x (cupy.ndarray): input data (must be real)

    Returns:
        cupy.ndarray: values of boxcox1p(x)

    .. seealso:: :data:`scipy.special.boxcox1p`

    z
static __device__ double inv_boxcox(double x, double lmbda) {
    if (lmbda == 0.0) {
        return exp(x);
    } else {
        return exp(log1p(lmbda * x) / lmbda);
    }
}

cupy_inv_boxcoxz&out0 = out0_type(inv_boxcox(in0, in1))zCompute the Box-Cox transformation.

    Args:
        x (cupy.ndarray): input data (must be real)

    Returns:
        cupy.ndarray: values of inv_boxcox(x)

    .. seealso:: :data:`scipy.special.inv_boxcox`

    z
static __device__ double inv_boxcox1p(double x, double lmbda) {
    if (lmbda == 0.0) {
        return expm1(x);
    } else if (fabs(lmbda * x) < 1e-154) {
        return x;
    } else {
        return expm1(log1p(lmbda * x) / lmbda);
    }
}

cupy_inv_boxcox1pz(out0 = out0_type(inv_boxcox1p(in0, in1))zCompute the Box-Cox transformation op 1 + `x`.

    Args:
        x (cupy.ndarray): input data (must be real)

    Returns:
        cupy.ndarray: values of inv_boxcox1p(x)

    .. seealso:: :data:`scipy.special.inv_boxcox1p`
N)
__future__r   cupyr   logit_definitioncreate_ufunclogitexpit_definitionexpitlog_expit_definition	log_expitboxcox_definitionboxcoxboxcox1p_definitionboxcox1pinv_boxcox_definition
inv_boxcoxinv_boxcox1p_definitioninv_boxcox1p r!   r!   U/home/ubuntu/vllm_env/lib/python3.10/site-packages/cupyx/scipy/special/_statistics.py<module>   st    
	
