
    tKg                         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 Z	g dZ
g d	Z ee
ddd         Z eeddd         Zd
 Zy)    N)poly1d)beta)gSbQ
@go|-a?g_3
L/g|A"?gCUG)      ?g<*x@g y@g`B{dA?g-~?c                 b   t        j                  |       } | j                  }t        j                  |       j	                  t         j
                        } d}| dk  }| dk(  }t        j                  |       |k  }||z  |z   }| |   }| |   }t        j                  |       }	t         j                  |	|<   t         j                  |	|<   |j                  dkD  rt        |      t        |      z  |	|<   |j                  dkD  r*d|dz  z  ddd|z  z   z  t        |dz   |dz         z
  z  |	|<   ||	_        |	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_maskneghalf_mask
small_maskreg_masksmallregvs
             b/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/scipy/stats/_tukeylambda_stats.pytukeylambda_variancer"   +   s,   . **S/C
))C
--

#
#BJJ
/C I
 TzH$;Ly(JL(:56H 
OE
h-C 	cA&&AhKffAlOzzA~*514Fu4MM*
xx!|S!V|sQW}(=(,S1WcAg(>)? @(AGH    )g333333?g6|igeSH6gѐ환^?g˝)kPd@)r   g?ݻA@gID@)@gPr?g`2fQc                    t        j                  |       } | j                  }t        j                  |       j	                  t         j
                        } d}| dk  }| dk(  }t        j                  |       |k  }||z  |z   }| |   }| |   }t        j                  |       }	t         j                  |	|<   t         j                  |	|<   |j                  dkD  rt        |      t        |      z  |	|<   |j                  dkD  rodd|z  dz   z  dt        d|z  dz   |dz         z  z
  dt        d|z  dz   d|z  dz         z  z   }
ddd|z  dz   z  t        |dz   |dz         z
  dz  z  }|
|z  dz
  |	|<   ||	_        |	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   negqrtr_maskr   r   r   r   knumerdenoms               r!   tukeylambda_kurtosisr-      s    **S/C
))C
--

#
#BJJ
/C I U{H%<Ly(JL(:56H 
OE
h-C 	cA&&AhKffAlOzzA~+E25H5OO*
xx!|C!$q4C!S1W+E'EET!c'A+q3w{334S!c'A+&cAgsQw)??!CCema'( AGHr#   )numpyr
   r   scipy.specialr   _tukeylambda_var_pc_tukeylambda_var_qcr   r   r"   _tukeylambda_kurt_pc_tukeylambda_kurt_qcr'   r(   r-    r#   r!   <module>r5      s      8- ? 
 /"56 /"56 9z? A 
 1$B$78 1$B$78 4r#   