§
    fŠtjø  ã                   ó¦   — d dl Z d dlZd dlmZmZmZmZ d dlm	c m
Z ddlmZ  e¦   «          ed„ dd„ ¬¦  «        dd	d
œd„¦   «         ¦   «         ZdS )é    N)Úarray_namespaceÚxp_capabilitiesÚ	xp_deviceÚ_length_nonmaskedé   )Ú_axis_nan_policy_factoryc                 ó   — | S ©N© )Úxs    úT/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/stats/_variation.pyú<lambda>r      s   € ˆa€ ó    c                 ó   — | fS r
   r   )r   Ú_s     r   r   r      s   € ¸A¸4€ r   )Ú	n_outputsÚresult_to_tupleÚ	propagateF)Úkeepdimsc                ó¸  — t          | ¦  «        }|                     | ¦  «        } |€|                     | d¦  «        } d}|                     t          | |¬¦  «        | j        t          | ¦  «        ¬¦  «        }t          j        dd¬¦  «        5  t          j	        ¦   «         5  t          j
        d¦  «         |                     | |¬¦  «        }|                     | |¬¦  «        }|||z
  z  dz  }	||	z  |z  }
ddd¦  «         n# 1 swxY w Y   ddd¦  «         n# 1 swxY w Y   d	„ }t          j        ||k    ||f||
¬
¦  «        }
|
j        dk    r|
d         n|
S )a�  
    Compute the coefficient of variation.

    The coefficient of variation is the standard deviation divided by the
    mean.  This function is equivalent to::

        np.std(x, axis=axis, ddof=ddof) / np.mean(x)

    The default for ``ddof`` is 0, but many definitions of the coefficient
    of variation use the square root of the unbiased sample variance
    for the sample standard deviation, which corresponds to ``ddof=1``.

    The function does not take the absolute value of the mean of the data,
    so the return value is negative if the mean is negative.

    Parameters
    ----------
    a : array_like
        Input array.
    axis : int or None, optional
        Axis along which to calculate the coefficient of variation.
        Default is 0. If None, compute over the whole array `a`.
    nan_policy : {'propagate', 'raise', 'omit'}, optional
        Defines how to handle when input contains ``nan``.
        The following options are available:

          * 'propagate': return ``nan``
          * 'raise': raise an exception
          * 'omit': perform the calculation with ``nan`` values omitted

        The default is 'propagate'.
    ddof : int, optional
        Gives the "Delta Degrees Of Freedom" used when computing the
        standard deviation.  The divisor used in the calculation of the
        standard deviation is ``N - ddof``, where ``N`` is the number of
        elements.  `ddof` must be less than ``N``; if it isn't, the result
        will be ``nan`` or ``inf``, depending on ``N`` and the values in
        the array.  By default `ddof` is zero for backwards compatibility,
        but it is recommended to use ``ddof=1`` to ensure that the sample
        standard deviation is computed as the square root of the unbiased
        sample variance.

    Returns
    -------
    variation : ndarray
        The calculated variation along the requested axis.

    Notes
    -----
    There are several edge cases that are handled without generating a
    warning:

    * If both the mean and the standard deviation are zero, ``nan``
      is returned.
    * If the mean is zero and the standard deviation is nonzero, ``inf``
      is returned.
    * If the input has length zero (either because the array has zero
      length, or all the input values are ``nan`` and ``nan_policy`` is
      ``'omit'``), ``nan`` is returned.
    * If the input contains ``inf``, ``nan`` is returned.

    References
    ----------
    .. [1] Zwillinger, D. and Kokoska, S. (2000). CRC Standard
       Probability and Statistics Tables and Formulae. Chapman & Hall: New
       York. 2000.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.stats import variation
    >>> variation([1, 2, 3, 4, 5], ddof=1)
    0.5270462766947299

    Compute the variation along a given dimension of an array that contains
    a few ``nan`` values:

    >>> x = np.array([[  10.0, np.nan, 11.0, 19.0, 23.0, 29.0, 98.0],
    ...               [  29.0,   30.0, 32.0, 33.0, 35.0, 56.0, 57.0],
    ...               [np.nan, np.nan, 12.0, 13.0, 16.0, 16.0, 17.0]])
    >>> variation(x, axis=1, ddof=1, nan_policy='omit')
    array([1.05109361, 0.31428986, 0.146483  ])

    N)éÿÿÿÿr   )Úaxis©ÚdtypeÚdeviceÚignore)ÚdivideÚinvalidg      à?c                 óè   — t          | |¦  «        }|                     |j        |j        t	          |¦  «        ¬¦  «        }|                     | dk    |                     ||¦  «        |j        ¦  «        S )Nr   r   )r   ÚasarrayÚinfr   r   ÚwhereÚcopysignÚnan)Ústd_aÚmean_aÚmxpÚ_xp_infs       r   Úspecial_casezvariation.<locals>.special_casey   s`   € å˜e VÑ,Ô,ˆð —+’+˜cœg¨V¬\Å)ÈFÑBSÔBS�+ÑTÔTˆØ�yŠy˜ š C§L¢L°¸&Ñ$AÔ$AÀ3Ä7ÑKÔKÐKr   )Ú
fill_valuer   )r   r    Úreshaper   r   r   ÚnpÚerrstateÚwarningsÚcatch_warningsÚsimplefilterÚmeanÚstdÚxpxÚapply_whereÚndim)Úar   Ú
nan_policyÚddofr   ÚxpÚnr&   r%   Ú
correctionÚresultr)   s               r   Ú	variationr=      sî  € õr 
˜Ñ	Ô	€BØ
�
Š
�1‰Œ€Að €|Ø�JŠJ�q˜%Ñ Ô ˆØˆà
�
Š
Õ$ Q¨TÐ2Ñ2Ô2¸!¼'Í)ÐTUÉ,Ì,ˆ
ÑWÔW€Aå
Œ+˜X¨xÐ
8Ñ
8Ô
8ð -ð -½(Ô:QÑ:SÔ:Sð -ð -ÝÔ˜hÑ'Ô'Ð'Ø—’˜ �Ñ&Ô&ˆØ—’�q˜t�Ñ$Ô$ˆØ˜1˜t™8‘n sÑ*ˆ
Ø˜Ñ# fÑ,ˆð-ð -ð -ñ -ô -ð -ð -ð -ð -ð -ð -øøøð -ð -ð -ð -ð -ð -ð -ñ -ô -ð -ð -ð -ð -ð -ð -øøøð -ð -ð -ð -ðLð Lð Lõ Œ_˜d aši¨5°&¨/Ø)°fð>ñ >ô >€Fð  œ¨Ò)Ð)ˆ6�"Œ:ˆ:¨vÐ5s7   ÂDÂ"ADÃ8DÄD	ÄDÄD	ÄDÄDÄ"D)r   r   r   )r.   Únumpyr,   Úscipy._lib._array_apir   r   r   r   Úscipy._lib.array_api_extraÚ_libÚarray_api_extrar3   Ú_axis_nan_policyr   r=   r   r   r   ú<module>rD      sø   ðØ €€€Ø Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð )Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ð (à 6Ð 6Ð 6Ð 6Ð 6Ð 6ð €ÑÔØÐØ€K˜1Ð.?Ð.?ðñ ô ðq6ÀUð q6ð q6ð q6ð q6ñô ñ Ôðq6ð q6ð q6r   