o
    Eb                     @   s   d dl Zd dl mZ d dlmZ g dZg dZeeddd Zeeddd Zdd Z	g d	Z
g d
Zee
ddd Zeeddd Zdd ZdS )    N)poly1d)beta)gSbQ
@go|-a?g_3
L/g|A"?gCUG)      ?g<*x@g y@g`B{dA?g-~?c           
      C   s   t | } | j}t | t j} d}| dk }| dk}t | |k }||B |B  }| | }| | }t | }	t j|	|< t j	|	|< |j
dkrOt|t| |	|< |j
dkrmd|d  ddd|   t|d |d   |	|< ||	_|	S )a  Variance of the Tukey Lambda distribution.

    Parameters
    ----------
    lam : array_like
        The lambda values at which to compute the variance.

    Returns
    -------
    v : ndarray
        The variance.  For lam < -0.5, the variance is not defined, so
        np.nan is returned.  For lam = 0.5, np.inf is returned.

    Notes
    -----
    In an interval around lambda=0, this function uses the [4,4] Pade
    approximation to compute the variance.  Otherwise it uses the standard
    formula (https://en.wikipedia.org/wiki/Tukey_lambda_distribution).  The
    Pade approximation is used because the standard formula has a removable
    discontinuity at lambda = 0, and does not produce accurate numerical
    results near lambda = 0.
    g333333?g      r   g       @   r      )npasarrayshape
atleast_1dastypefloat64abs
empty_likenaninfsize_tukeylambda_var_p_tukeylambda_var_qr   )
lamshp	thresholdlow_maskZneghalf_mask
small_maskreg_masksmallregv r   @/usr/lib/python3/dist-packages/scipy/stats/_tukeylambda_stats.pytukeylambda_variance+   s*   






r    )g333333?g6|igeSH6gѐ환^?g˝)kPd@)r   g?ݻA@gID@)@gPr?g`2fQc                 C   s4  t | } | j}t | t j} d}| dk }| dk}t | |k }||B |B  }| | }| | }t | }	t j|	|< t j	|	|< |j
dkrOt|t| |	|< |j
dkrdd| d  dtd| d |d   dtd| d d| d   }
ddd| d  t|d |d  d  }|
| d |	|< ||	_|	S )	aR  Kurtosis of the Tukey Lambda distribution.

    Parameters
    ----------
    lam : array_like
        The lambda values at which to compute the variance.

    Returns
    -------
    v : ndarray
        The variance.  For lam < -0.25, the variance is not defined, so
        np.nan is returned.  For lam = 0.25, np.inf is returned.

    g)\(?g      пr   r      r      r   )r   r	   r
   r   r   r   r   r   r   r   r   _tukeylambda_kurt_p_tukeylambda_kurt_qr   )r   r   r   r   Znegqrtr_maskr   r   r   r   kZnumerZdenomr   r   r   tukeylambda_kurtosis   s.   





(*r&   )Znumpyr   r   Zscipy.specialr   Z_tukeylambda_var_pcZ_tukeylambda_var_qcr   r   r    Z_tukeylambda_kurt_pcZ_tukeylambda_kurt_qcr#   r$   r&   r   r   r   r   <module>   s    ]