Ë
    âQ(hç  ã                   óˆ   — d dl Zd dlmZ d dlmZmZmZ d dlm	Z	 dgZ
d„ Zd„ Zd„ Zd	„ Z e	ed
dedd¬«      d dddœd„«       Zy)é    N)Ústats)Ú_SimpleNormalÚSignificanceResultÚ_get_pvalue)Ú_axis_nan_policy_factoryÚchatterjeexic                 ó  — | j                   d   }t        j                  | d¬«      }t        j                  ||«      \  }}t        j                  ||d¬«      }t        j                  |dd¬«      }t        j                  | dd¬«      }t        j                  t        j                  t        j                  |d¬«      «      d¬«      }|rdd|z  |dz  dz
  z  z
  }n+dt        j                  ||z
  |z  d¬«      z  }	d||z  |	z  z
  }|||fS )Néÿÿÿÿ©ÚaxisÚmax)Úmethodr   é   é   é   )
ÚshapeÚnpÚargsortÚbroadcast_arraysÚtake_along_axisr   ÚrankdataÚsumÚabsÚdiff)
ÚxÚyÚy_continuousÚnÚjÚrÚlÚnumÚ	statisticÚdens
             úV/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/stats/_correlation.pyÚ_xi_statisticr&      sô   € ð 	
�‰�‰€Aô 	�
‰
�1˜2Ô€AÜ×Ñ˜q !Ó$�D€A€qÜ
×Ñ˜1˜a bÔ)€Aô 	�‰�q ¨RÔ0€Aô 	�‰˜�r %¨bÔ1€Aä
�&‰&”—‘œŸ™ ¨Ô+Ó,°2Ô
6€CÙØ˜˜C™ 1¨¡6¨A¡:Ñ.Ñ.‰	à”"—&‘&˜!˜a™% 1™¨2Ô.Ñ.ˆØ˜˜C™ #™Ñ%ˆ	à�a˜ˆ?Ðó    c                 ó  — t        j                  | j                  d   «      }|r+t        j                  d«      t        j                  |«      z  S t        j                  d|dz   «      }t        j
                  | d¬«      }t        j                  |d¬«      }d|dz  z  t        j                  d|z  d|z  z
  dz   |dz  z  d¬«      z  }d|dz  z  t        j                  |||z
  |z  z   dz  d¬«      z  }d|dz  z  t        j                  d|z  d|z  z
  dz   |z  d¬«      z  }	d|dz  z  t        j                  |||z
  z  d¬«      z  }
|d|z  z
  |	dz  z   |
dz  z  }t        j                  |«      t        j                  |«      z  S )	Nr
   gš™™™™™Ù?r   r   é   r   é   r   )r   Úfloat64r   ÚsqrtÚarangeÚsortÚcumsumr   )r    r!   r   r   ÚiÚuÚvÚanÚbnÚcnÚdnÚtau2s               r%   Ú_xi_stdr8   *   se  € ô 	�
‰
�1—7‘7˜2‘;Ó€Añ Ü�w‰w�u‹~¤§¡¨£
Ñ*Ð*ô
 	�	‰	�!�Q˜‘UÓ€AÜ
�‰�˜Ô€AÜ
�	‰	�!˜"Ô€AØ	
ˆQ�‰T‰”B—F‘F˜A˜a™C ! A¡#™I¨™M¨Q°©TÑ1¸Ô;Ñ	;€BØ	
ˆQ�‰T‰”B—F‘F˜A  Q¡¨¡	™M¨AÑ-°BÔ7Ñ	7€BØ	
ˆQ�‰T‰”B—F‘F˜A˜a™C ! A¡#™I¨™M¨QÑ.°RÔ8Ñ	8€BØ	
ˆQ�‰T‰”B—F‘F˜A  Q¡™K¨rÔ2Ñ	2€BØ��2‘‰I˜˜A™Ñ  Q¡Ñ&€Dä�7‰7�4‹=œ2Ÿ7™7 1›:Ñ%Ð%r'   c                 ó    — | dvrt        d«      ‚t        |t        j                  «      s"|j	                  «       }d}|dk7  rt        |«      ‚| |fS )N>   FTz`y_continuous` must be boolean.z@`method` must be 'asymptotic' or a `PermutationMethod` instance.Ú
asymptotic)Ú
ValueErrorÚ
isinstancer   ÚPermutationMethodÚlower)r   r   Úmessages      r%   Ú_chatterjeexi_ivr@   D   sV   € ð ˜=Ñ(ÜÐ:Ó;Ð;ä�fœe×5Ñ5Ô6Ø—‘“ˆØTˆØ�\Ò!Ü˜WÓ%Ð%à˜ÐÐr'   c                 ó2   — | j                   | j                  fS )N)r#   Úpvalue)Úress    r%   Ú_unpackrD   T   s   € Ø�=‰=˜#Ÿ*™*Ð$Ð$r'   Tr   r   )ÚpairedÚ	n_samplesÚresult_to_tupleÚ	n_outputsÚ	too_smallFr:   )r   r   r   c                ó„  ‡ ‡— t        ‰|«      \  Š}d}|dk(  r:t        ‰ |‰«      \  }}}t        ||‰«      }	t        «       }
t	        ||	z  |
|¬«      }nct        |t        j                  «      rIt        j                  d	|fˆ ˆfd„|ddœ|j                  «       ¤ddi¤Ž}|j                  |j                  }}t        «      S )
a˜  Compute the xi correlation and perform a test of independence

    The xi correlation coefficient is a measure of association between two
    variables; the value tends to be close to zero when the variables are
    independent and close to 1 when there is a strong association. Unlike
    other correlation coefficients, the xi correlation is effective even
    when the association is not monotonic.

    Parameters
    ----------
    x, y : array-like
        The samples: corresponding observations of the independent and
        dependent variable. The (N-d) arrays must be broadcastable.
    axis : int, default: 0
        Axis along which to perform the test.
    method : 'asymptotic' or `PermutationMethod` instance, optional
        Selects the method used to calculate the *p*-value.
        Default is 'asymptotic'. The following options are available.

        * ``'asymptotic'``: compares the standardized test statistic
          against the normal distribution.
        * `PermutationMethod` instance. In this case, the p-value
          is computed using `permutation_test` with the provided
          configuration options and other appropriate settings.

    y_continuous : bool, default: False
        Whether `y` is assumed to be drawn from a continuous distribution.
        If `y` is drawn from a continuous distribution, results are valid
        whether this is assumed or not, but enabling this assumption will
        result in faster computation and typically produce similar results.

    Returns
    -------
    res : SignificanceResult
        An object containing attributes:

        statistic : float
            The xi correlation statistic.
        pvalue : float
            The associated *p*-value: the probability of a statistic at least as
            high as the observed value under the null hypothesis of independence.

    See Also
    --------
    scipy.stats.pearsonr, scipy.stats.spearmanr, scipy.stats.kendalltau

    Notes
    -----
    There is currently no special handling of ties in `x`; they are broken arbitrarily
    by the implementation.

    [1]_ notes that the statistic is not symmetric in `x` and `y` *by design*:
    "...we may want to understand if :math:`Y` is a function :math:`X`, and not just
    if one of the variables is a function of the other." See [1]_ Remark 1.

    References
    ----------
    .. [1] Chatterjee, Sourav. "A new coefficient of correlation." Journal of
           the American Statistical Association 116.536 (2021): 2009-2022.
           :doi:`10.1080/01621459.2020.1758115`.

    Examples
    --------
    Generate perfectly correlated data, and observe that the xi correlation is
    nearly 1.0.

    >>> import numpy as np
    >>> from scipy import stats
    >>> rng = np.random.default_rng(348932549825235)
    >>> x = rng.uniform(0, 10, size=100)
    >>> y = np.sin(x)
    >>> res = stats.chatterjeexi(x, y)
    >>> res.statistic
    np.float64(0.9012901290129013)

    The probability of observing such a high value of the statistic under the
    null hypothesis of independence is very low.

    >>> res.pvalue
    np.float64(2.2206974648177804e-46)

    As noise is introduced, the correlation coefficient decreases.

    >>> noise = rng.normal(scale=[[0.1], [0.5], [1]], size=(3, 100))
    >>> res = stats.chatterjeexi(x, y + noise, axis=-1)
    >>> res.statistic
    array([0.79507951, 0.41824182, 0.16651665])

    Because the distribution of `y` is continuous, it is valid to pass
    ``y_continuous=True``. The statistic is identical, and the p-value
    (not shown) is only slightly different.

    >>> stats.chatterjeexi(x, y + noise, y_continuous=True, axis=-1).statistic
    array([0.79507951, 0.41824182, 0.16651665])

    Úgreaterr:   )Úalternativec                 ó$   •— t        ‰| ‰«      d   S )Nr   )r&   )r   r   r   r   s     €€r%   ú<lambda>zchatterjeexi.<locals>.<lambda>Ì   s   ø€ ´¸qÀ!À\Ó1RÐSTÑ1U€ r'   Úpairings)Údatar#   rL   Úpermutation_typer   r
   © )r@   r&   r8   r   r   r<   r   r=   Úpermutation_testÚ_asdictr#   rB   r   )r   r   r   r   r   rL   Úxir    r!   ÚstdÚnormrB   rC   s   `  `         r%   r   r   X   sÐ   ù€ ôJ ,¨L¸&ÓAÑ€L�&ð
 €Kà�ÒÜ   A |Ó4‰ˆˆAˆqÜ�a˜˜LÓ)ˆÜ‹ˆÜ˜R #™X t¸ÔE‰Ü	�FœE×3Ñ3Ô	4Ü×$Ñ$ð à�Ô!UØ#°jñð EKÇNÁNÓDTñð ò	ˆð —]‘] C§J¡JˆFˆä˜b &Ó)Ð)r'   )Únumpyr   Úscipyr   Úscipy.stats._stats_pyr   r   r   Úscipy.stats._axis_nan_policyr   Ú__all__r&   r8   r@   rD   r   rR   r'   r%   ú<module>r]      sd   ðÛ Ý ß PÑ PÝ Að Ð
€òò8&ò4 ò %ñ Ð,°TÀQØ*1¸QÈ!ôMà ¨u¸\ó x*óMñx*r'   