§
    fŠtj[d  ã                   ó¸   — d dl mZmZ d dlmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ d dlZddlmZmZ ddlmZ dgZ G d	„ d¦  «        Zd
„ ZdS )é    )ÚlinalgÚspecial)Úcheck_random_stateÚ	np_vecdot)ÚasarrayÚ
atleast_2dÚreshapeÚzerosÚnewaxisÚexpÚpiÚsqrtÚravelÚpowerÚ
atleast_1dÚsqueezeÚsumÚ	transposeÚonesÚcovNé   )Úgaussian_kernel_estimateÚgaussian_kernel_estimate_log)Úmultivariate_normalÚgaussian_kdec                   óÌ   — e Zd ZdZdd„Zd„ ZeZd„ Zd„ Zdddœd„Z	d	„ Z
dd
„Zd„ Zd„ ZeZde_        dd„Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zed„ ¦   «         Zed„ ¦   «         ZdS )r   a­  Representation of a kernel-density estimate using Gaussian kernels.

    Kernel density estimation is a way to estimate the probability density
    function (PDF) of a random variable in a non-parametric way.
    `gaussian_kde` works for both uni-variate and multi-variate data.   It
    includes automatic bandwidth determination.  The estimation works best for
    a unimodal distribution; bimodal or multi-modal distributions tend to be
    oversmoothed.

    Parameters
    ----------
    dataset : array_like
        Datapoints to estimate from. In case of univariate data this is a 1-D
        array, otherwise a 2-D array with shape (# of dims, # of data).
    bw_method : str, scalar or callable, optional
        The method used to calculate the bandwidth factor.  This can be
        'scott', 'silverman', a scalar constant or a callable.  If a scalar,
        this will be used directly as `factor`.  If a callable, it should
        take a `gaussian_kde` instance as only parameter and return a scalar.
        If None (default), 'scott' is used.  See Notes for more details.
    weights : array_like, optional
        weights of datapoints. This must be the same shape as dataset.
        If None (default), the samples are assumed to be equally weighted

    Attributes
    ----------
    dataset : ndarray
        The dataset with which `gaussian_kde` was initialized.
    d : int
        Number of dimensions.
    n : int
        Number of datapoints.
    neff : int
        Effective number of datapoints.

        .. versionadded:: 1.2.0
    factor : float
        The bandwidth factor obtained from `covariance_factor`.
    covariance : ndarray
        The kernel covariance matrix; this is the data covariance matrix
        multiplied by the square of the bandwidth factor, e.g.
        ``np.cov(dataset) * factor**2``.
    inv_cov : ndarray
        The inverse of `covariance`.

    Methods
    -------
    evaluate
    __call__
    integrate_gaussian
    integrate_box_1d
    integrate_box
    integrate_kde
    pdf
    logpdf
    resample
    set_bandwidth
    covariance_factor
    marginal

    Notes
    -----
    Bandwidth selection strongly influences the estimate obtained from the KDE
    (much more so than the actual shape of the kernel).  Bandwidth selection
    can be done by a "rule of thumb", by cross-validation, by "plug-in
    methods" or by other means; see [3]_, [4]_ for reviews.  `gaussian_kde`
    uses a rule of thumb, the default is Scott's Rule.

    Scott's Rule [1]_, implemented as `scotts_factor`, is::

        n**(-1./(d+4)),

    with ``n`` the number of data points and ``d`` the number of dimensions.
    In the case of unequally weighted points, `scotts_factor` becomes::

        neff**(-1./(d+4)),

    with ``neff`` the effective number of datapoints.
    Silverman's suggestion for *multivariate* data [2]_, implemented as
    `silverman_factor`, is::

        (n * (d + 2) / 4.)**(-1. / (d + 4)).

    or in the case of unequally weighted points::

        (neff * (d + 2) / 4.)**(-1. / (d + 4)).

    Note that this is not the same as "Silverman's rule of thumb" [6]_, which
    may be more robust in the univariate case; see documentation of the
    ``set_bandwidth`` method for implementing a custom bandwidth rule.

    Good general descriptions of kernel density estimation can be found in [1]_
    and [2]_, the mathematics for this multi-dimensional implementation can be
    found in [1]_.

    With a set of weighted samples, the effective number of datapoints ``neff``
    is defined by::

        neff = sum(weights)^2 / sum(weights^2)

    as detailed in [5]_.

    `gaussian_kde` does not currently support data that lies in a
    lower-dimensional subspace of the space in which it is expressed. For such
    data, consider performing principal component analysis / dimensionality
    reduction and using `gaussian_kde` with the transformed data.

    References
    ----------
    .. [1] D.W. Scott, "Multivariate Density Estimation: Theory, Practice, and
           Visualization", John Wiley & Sons, New York, Chicester, 1992.
    .. [2] B.W. Silverman, "Density Estimation for Statistics and Data
           Analysis", Vol. 26, Monographs on Statistics and Applied Probability,
           Chapman and Hall, London, 1986.
    .. [3] B.A. Turlach, "Bandwidth Selection in Kernel Density Estimation: A
           Review", CORE and Institut de Statistique, Vol. 19, pp. 1-33, 1993.
    .. [4] D.M. Bashtannyk and R.J. Hyndman, "Bandwidth selection for kernel
           conditional density estimation", Computational Statistics & Data
           Analysis, Vol. 36, pp. 279-298, 2001.
    .. [5] Gray P. G., 1969, Journal of the Royal Statistical Society.
           Series A (General), 132, 272
    .. [6] Kernel density estimation. *Wikipedia.*
           https://en.wikipedia.org/wiki/Kernel_density_estimation

    Examples
    --------
    Generate some random two-dimensional data:

    >>> import numpy as np
    >>> from scipy import stats
    >>> def measure(n):
    ...     "Measurement model, return two coupled measurements."
    ...     m1 = np.random.normal(size=n)
    ...     m2 = np.random.normal(scale=0.5, size=n)
    ...     return m1+m2, m1-m2

    >>> m1, m2 = measure(2000)
    >>> xmin = m1.min()
    >>> xmax = m1.max()
    >>> ymin = m2.min()
    >>> ymax = m2.max()

    Perform a kernel density estimate on the data:

    >>> X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]
    >>> positions = np.vstack([X.ravel(), Y.ravel()])
    >>> values = np.vstack([m1, m2])
    >>> kernel = stats.gaussian_kde(values)
    >>> Z = np.reshape(kernel(positions).T, X.shape)

    Plot the results:

    >>> import matplotlib.pyplot as plt
    >>> fig, ax = plt.subplots()
    >>> ax.imshow(np.rot90(Z), cmap=plt.cm.gist_earth_r,
    ...           extent=[xmin, xmax, ymin, ymax])
    >>> ax.plot(m1, m2, 'k.', markersize=2)
    >>> ax.set_xlim([xmin, xmax])
    >>> ax.set_ylim([ymin, ymax])
    >>> plt.show()

    Compare against manual KDE at a point:

    >>> point = [1, 2]
    >>> mean = values.T
    >>> cov = kernel.factor**2 * np.cov(values)
    >>> X = stats.multivariate_normal(cov=cov)
    >>> res = kernel.pdf(point)
    >>> ref = X.pdf(point - mean).sum() / len(mean)
    >>> np.allclose(res, ref)
    True
    Nc                 óþ  — t          t          |¦  «        ¦  «        | _        | j        j        dk    st	          d¦  «        ‚| j        j        \  | _        | _        |�»t          |¦  «         	                    t          ¦  «        | _        | xj        t          | j        ¦  «        z  c_        | j        j        dk    rt	          d¦  «        ‚t          | j        ¦  «        | j        k    rt	          d¦  «        ‚dt!          | j        | j        ¦  «        z  | _        | j        | j        k    rd}t	          |¦  «        ‚	 |                      |¬¦  «         d S # t&          j        $ r}d}t'          j        |¦  «        |‚d }~ww xY w)Nr   z.`dataset` input should have multiple elements.z*`weights` input should be one-dimensional.z%`weights` input should be of length na1  Number of dimensions is greater than number of samples. This results in a singular data covariance matrix, which cannot be treated using the algorithms implemented in `gaussian_kde`. Note that `gaussian_kde` interprets each *column* of `dataset` to be a point; consider transposing the input to `dataset`.©Ú	bw_methodab  The data appears to lie in a lower-dimensional subspace of the space in which it is expressed. This has resulted in a singular data covariance matrix, which cannot be treated using the algorithms implemented in `gaussian_kde`. Consider performing principal component analysis / dimensionality reduction and using `gaussian_kde` with the transformed data.)r   r   ÚdatasetÚsizeÚ
ValueErrorÚshapeÚdÚnr   ÚastypeÚfloatÚ_weightsr   ÚweightsÚndimÚlenr   Ú_neffÚset_bandwidthr   ÚLinAlgError)Úselfr    r   r)   ÚmsgÚes         úN/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/stats/_kde.pyÚ__init__zgaussian_kde.__init__Ñ   sj  € Ý!¥'¨'Ñ"2Ô"2Ñ3Ô3ˆŒØŒ|Ô  1Ò$Ð$ÝÐMÑNÔNÐNàœÔ+‰ˆŒ�”àÐÝ& wÑ/Ô/×6Ò6µuÑ=Ô=ˆDŒMØˆMŒM�S ¤Ñ/Ô/Ñ/ˆMŒMØŒ|Ô  AÒ%Ð%Ý Ð!MÑNÔNÐNÝ�4”=Ñ!Ô! T¤VÒ+Ð+Ý Ð!HÑIÔIÐIØ�9 T¤]°D´MÑBÔBÑBˆDŒJð Œ6�D”FŠ?ˆ?ð-ˆCõ ˜S‘/”/Ð!ð
	1Ø×Ò¨ÐÑ3Ô3Ð3Ð3Ð3øÝÔ!ð 	1ð 	1ð 	1ð?ˆCõ Ô$ SÑ)Ô)¨qÐ0øøøøð	1øøøs   Ä9E ÅE<Å E7Å7E<c                 ó²  — t          t          |¦  «        ¦  «        }|j        \  }}|| j        k    rG|dk    r%|| j        k    rt	          || j        df¦  «        }d}nd|› d| j        › �}t          |¦  «        ‚t          | j        |¦  «        \  }}t          |         | j	        j
        | j        dd…df         |j
        | j        |¦  «        }|dd…df         S )a  Evaluate the estimated pdf on a set of points.

        Parameters
        ----------
        points : (# of dimensions, # of points)-array
            Alternatively, a (# of dimensions,) vector can be passed in and
            treated as a single point.

        Returns
        -------
        values : (# of points,)-array
            The values at each point.

        Raises
        ------
        ValueError : if the dimensionality of the input points is different than
                     the dimensionality of the KDE.

        r   úpoints have dimension ú, dataset has dimension Nr   )r   r   r#   r$   r	   r"   Ú_get_output_dtypeÚ
covariancer   r    ÚTr)   Úcho_cov)r/   Úpointsr$   Úmr0   Úoutput_dtypeÚspecÚresults           r2   Úevaluatezgaussian_kde.evaluate÷   së   € õ( �G F™OœOÑ,Ô,ˆàŒ|‰ˆˆ1Ø�”Š;ˆ;Ø�AŠvˆv˜!˜tœvš+˜+å  ¨$¬&°!¨Ñ5Ô5�Ø��ð9°ð 9ð 9Ø04´ð9ð 9�å  ‘o”oÐ%å.¨t¬ÀÑGÔGÑˆ�dÝ)¨$Ô/ØŒLŒN˜DœL¨¨¨¨D¨Ô1ØŒH�d”l Lñ2ô 2ˆð �a�a�a˜�dŒ|Ðó    c                 óÈ  — t          t          |¦  «        ¦  «        }t          |¦  «        }|j        | j        fk    rt          d| j        › �¦  «        ‚|j        | j        | j        fk    rt          d| j        › �¦  «        ‚|dd…t          f         }| j        |z   }t          j	        |¦  «        }| j
        |z
  }t          j        ||¦  «        }t          j        t          j        |d         ¦  «        ¦  «        }t          dt           z  |j        d         dz  ¦  «        |z  }t#          ||d¬¦  «        dz  }	t#          t%          |	 ¦  «        | j        d¬¦  «        |z  }
|
S )aW  
        Multiply estimated density by a multivariate Gaussian and integrate
        over the whole space.

        Parameters
        ----------
        mean : aray_like
            A 1-D array, specifying the mean of the Gaussian.
        cov : array_like
            A 2-D array, specifying the covariance matrix of the Gaussian.

        Returns
        -------
        result : scalar
            The value of the integral.

        Raises
        ------
        ValueError
            If the mean or covariance of the input Gaussian differs from
            the KDE's dimensionality.

        zmean does not have dimension z#covariance does not have dimension Nr   é   ç       @©Úaxis)r   r   r   r#   r$   r"   r   r8   r   Ú
cho_factorr    Ú	cho_solveÚnpÚprodÚdiagonalr   r   r   r   r)   )r/   Úmeanr   Úsum_covÚsum_cov_cholÚdiffÚtdiffÚsqrt_detÚ
norm_constÚenergiesr?   s              r2   Úintegrate_gaussianzgaussian_kde.integrate_gaussian!  sM  € õ0 �' $™-œ-Ñ(Ô(ˆÝ˜‰oŒoˆàŒ:˜$œ&˜Ò"Ð"ÝÐE¸T¼VÐEÐEÑFÔFÐFØŒ9˜œ ¤Ð(Ò(Ð(ÝÐKÀ4Ä6ÐKÐKÑLÔLÐLð �A�A�A•w�JÔˆà”/ CÑ'ˆõ
 Ô(¨Ñ1Ô1ˆàŒ|˜dÑ"ˆÝÔ  ¨tÑ4Ô4ˆå”7�2œ; |°A¤Ñ7Ô7Ñ8Ô8ˆÝ˜1�r™6 7¤=°Ô#3°cÑ#9Ñ:Ô:¸XÑEˆ
å˜T 5¨qÐ1Ñ1Ô1°CÑ7ˆÝ�3 ˜y™>œ>¨4¬<¸aÐ@Ñ@Ô@À:ÑMˆàˆrA   c                 ól  — | j         dk    rt          d¦  «        ‚t          t          | j        ¦  «        ¦  «        d         }t          || j        z
  |z  ¦  «        }t          || j        z
  |z  ¦  «        }t          j        |¦  «        t          j        |¦  «        z
  }t          | j	        |¦  «        }|S )a´  
        Computes the integral of a 1D pdf between two bounds.

        Parameters
        ----------
        low : scalar
            Lower bound of integration.
        high : scalar
            Upper bound of integration.

        Returns
        -------
        value : scalar
            The result of the integral.

        Raises
        ------
        ValueError
            If the KDE is over more than one dimension.

        r   z'integrate_box_1d() only handles 1D pdfsr   )
r$   r"   r   r   r8   r    r   Úndtrr   r)   )r/   ÚlowÚhighÚstdevÚnormalized_lowÚnormalized_highÚdeltaÚvalues           r2   Úintegrate_box_1dzgaussian_kde.integrate_box_1dV  s    € ð, Œ6�QŠ;ˆ;ÝÐFÑGÔGÐGå•d˜4œ?Ñ+Ô+Ñ,Ô,¨QÔ/ˆå  d¤lÑ 2°eÑ;Ñ<Ô<ˆÝ ¨¬Ñ!4¸Ñ =Ñ>Ô>ˆå”˜_Ñ-Ô-µ´¸^Ñ0LÔ0LÑLˆÝ˜$œ,¨Ñ.Ô.ˆØˆrA   )Úrngc                ó¨   — || j         j        z
  || j         j        z
  }}t          j        ||| j        ||¬¦  «        }t          || j        d¬¦  «        S )aF  Computes the integral of a pdf over a rectangular interval.

        Parameters
        ----------
        low_bounds : array_like
            A 1-D array containing the lower bounds of integration.
        high_bounds : array_like
            A 1-D array containing the upper bounds of integration.
        maxpts : int, optional
            The maximum number of points to use for integration.
        rng : `numpy.random.Generator`, optional
            Pseudorandom number generator state. When `rng` is None, a new
            generator is created using entropy from the operating system. Types
            other than `numpy.random.Generator` are passed to
            `numpy.random.default_rng` to instantiate a ``Generator``.

        Returns
        -------
        value : scalar
            The result of the integral.

        )Úlower_limitr   Úmaxptsr_   éÿÿÿÿrE   )r    r9   r   Úcdfr8   r   r)   )r/   Ú
low_boundsÚhigh_boundsrb   r_   rW   rX   Úvaluess           r2   Úintegrate_boxzgaussian_kde.integrate_boxx  s]   € ð.  ¤¤Ñ/°¸t¼|¼~Ñ1MˆTˆÝ$Ô(Ø˜c t¤¸vØð
ñ 
ô 
ˆõ ˜ ¤°BÐ7Ñ7Ô7Ð7rA   c                 ó¤  — |j         | j         k    rt          d¦  «        ‚|j        | j        k     r|}| }n| }|}|j        |j        z   }t	          j        |¦  «        }d}t          |j        ¦  «        D ]ƒ}|j        dd…|t          f         }|j        |z
  }	t	          j	        ||	¦  «        }
t          |	|
d¬¦  «        dz  }|t          t          | ¦  «        |j        d¬¦  «        |j        |         z  z  }Œ„t          j        t          j        |d         ¦  «        ¦  «        }t!          dt"          z  |j        d         dz  ¦  «        |z  }||z  }|S )aŸ  
        Computes the integral of the product of this  kernel density estimate
        with another.

        Parameters
        ----------
        other : gaussian_kde instance
            The other kde.

        Returns
        -------
        value : scalar
            The result of the integral.

        Raises
        ------
        ValueError
            If the KDEs have different dimensionality.

        z$KDEs are not the same dimensionalityg        Nr   rE   rD   rC   )r$   r"   r%   r8   r   rG   Úranger    r   rH   r   r   r)   rI   rJ   rK   r   r   r#   )r/   ÚotherÚsmallÚlargerM   rN   r?   ÚirL   rO   rP   rS   rQ   rR   s                 r2   Úintegrate_kdezgaussian_kde.integrate_kde–  sV  € ð* Œ7�d”fÒÐÝÐCÑDÔDÐDð Œ7�T”VÒÐØˆEØˆEˆEàˆEØˆEàÔ" UÔ%5Ñ5ˆÝÔ(¨Ñ1Ô1ˆØˆÝ�u”w‘”ð 	Xð 	XˆAØ”=    A¥w Ô/ˆDØ”= 4Ñ'ˆDÝÔ$ \°4Ñ8Ô8ˆEå   u°1Ð5Ñ5Ô5¸Ñ;ˆHØ•i¥ X I¡¤°´ÀAÐFÑFÔFÀuÄ}ÐUVÔGWÑWÑWˆFˆFå”7�2œ; |°A¤Ñ7Ô7Ñ8Ô8ˆÝ˜1�r™6 7¤=°Ô#3°cÑ#9Ñ:Ô:¸XÑEˆ
à�*ÑˆàˆrA   c                 óB  — |€t          | j        ¦  «        }t          |¦  «        }t          |                     t          | j        ft          ¦  «        | j        |¬¦  «        ¦  «        }| 	                    | j
        || j        ¬¦  «        }| j        dd…|f         }||z   S )aA  Randomly sample a dataset from the estimated pdf.

        Parameters
        ----------
        size : int, optional
            The number of samples to draw.  If not provided, then the size is
            the same as the effective number of samples in the underlying
            dataset.
        seed : {None, int, `numpy.random.Generator`, `numpy.random.RandomState`}, optional
            If `seed` is None (or `np.random`), the `numpy.random.RandomState`
            singleton is used.
            If `seed` is an int, a new ``RandomState`` instance is used,
            seeded with `seed`.
            If `seed` is already a ``Generator`` or ``RandomState`` instance then
            that instance is used.

        Returns
        -------
        resample : (self.d, `size`) ndarray
            The sampled dataset.

        N)r!   )r!   Úp)ÚintÚneffr   r   r   r
   r$   r'   r8   Úchoicer%   r)   r    )r/   r!   ÚseedÚrandom_stateÚnormÚindicesÚmeanss          r2   Úresamplezgaussian_kde.resampleÈ  sž   € ð. ˆ<Ý�t”y‘>”>ˆDå)¨$Ñ/Ô/ˆÝ˜×9Ò9Ý�4”6�)�UÑ#Ô# T¤_¸4ð :ñ 
ô 
ñ ô ˆð ×%Ò% d¤f°4¸4¼<Ð%ÑHÔHˆØ”˜Q˜Q˜Q ˜ZÔ(ˆà�t‰|ÐrA   c                 óB   — t          | j        d| j        dz   z  ¦  «        S )zoCompute Scott's factor.

        Returns
        -------
        s : float
            Scott's factor.
        ç      ð¿é   ©r   rs   r$   ©r/   s    r2   Úscotts_factorzgaussian_kde.scotts_factorë  s    € õ �T”Y  T¤V¨A¡X¡Ñ/Ô/Ð/rA   c                 ó^   — t          | j        | j        dz   z  dz  d| j        dz   z  ¦  «        S )z{Compute the Silverman factor.

        Returns
        -------
        s : float
            The silverman factor.
        rD   g      @r|   r}   r~   r   s    r2   Úsilverman_factorzgaussian_kde.silverman_factorõ  s0   € õ �T”Y ¤ s¡
Ñ+¨CÑ/°°d´f¸Q±h±Ñ@Ô@Ð@rA   zÑComputes the bandwidth factor `factor`.
        The default is `scotts_factor`.  A subclass can overwrite this
        method to provide a different method, or set it through a call to
        `set_bandwidth`.c                 ó^  ‡ ‡— ‰€n“‰dk    r‰ j         ‰ _        n€‰dk    r‰ j        ‰ _        nmt          j        ‰¦  «        r't          ‰t          ¦  «        sd‰ _        ˆfd„‰ _        n2t          ‰¦  «        r‰‰ _        ˆ fd„‰ _        nd}t          |¦  «        ‚‰  
                    ¦   «          dS )aJ  Compute the bandwidth factor with given method.

        The new bandwidth calculated after a call to `set_bandwidth` is used
        for subsequent evaluations of the estimated density.

        Parameters
        ----------
        bw_method : str, scalar or callable, optional
            The method used to calculate the bandwidth factor.  This can be
            'scott', 'silverman', a scalar constant or a callable.  If a
            scalar, this will be used directly as `factor`.  If a callable,
            it should take a `gaussian_kde` instance as only parameter and
            return a scalar.  If None (default), nothing happens; the current
            `covariance_factor` method is kept.

        Notes
        -----
        .. versionadded:: 0.11

        Examples
        --------
        >>> import numpy as np
        >>> import scipy.stats as stats
        >>> x1 = np.array([-7, -5, 1, 4, 5.])
        >>> kde = stats.gaussian_kde(x1)
        >>> xs = np.linspace(-10, 10, num=50)
        >>> y1 = kde(xs)
        >>> kde.set_bandwidth(bw_method='silverman')
        >>> y2 = kde(xs)
        >>> kde.set_bandwidth(bw_method=kde.factor / 3.)
        >>> y3 = kde(xs)

        >>> import matplotlib.pyplot as plt
        >>> fig, ax = plt.subplots()
        >>> ax.plot(x1, np.full(x1.shape, 1 / (4. * x1.size)), 'bo',
        ...         label='Data points (rescaled)')
        >>> ax.plot(xs, y1, label='Scott (default)')
        >>> ax.plot(xs, y2, label='Silverman')
        >>> ax.plot(xs, y3, label='Const (1/3 * Silverman)')
        >>> ax.legend()
        >>> plt.show()

        NÚscottÚ	silvermanzuse constantc                  ó   •— ‰ S ©N© r   s   €r2   ú<lambda>z,gaussian_kde.set_bandwidth.<locals>.<lambda>:  s   ø€ ¨Y€ rA   c                  ó.   •— ‰                       ‰ ¦  «        S r‡   )Ú
_bw_methodr   s   €r2   r‰   z,gaussian_kde.set_bandwidth.<locals>.<lambda>=  s   ø€ ¨T¯_ª_¸TÑ-BÔ-B€ rA   zC`bw_method` should be 'scott', 'silverman', a scalar or a callable.)r€   Úcovariance_factorr‚   rI   ÚisscalarÚ
isinstanceÚstrr‹   Úcallabler"   Ú_compute_covariance)r/   r   r0   s   `` r2   r-   zgaussian_kde.set_bandwidth  sÖ   øø€ ðX ÐØØ˜'Ò!Ð!Ø%)Ô%7ˆDÔ"Ð"Ø˜+Ò%Ð%Ø%)Ô%:ˆDÔ"Ð"ÝŒ[˜Ñ#Ô#ð 		"­J°yÅ#Ñ,FÔ,Fð 		"Ø,ˆDŒOØ%6Ð%6Ð%6Ð%6ˆDÔ"Ð"Ý�iÑ Ô ð 	"Ø'ˆDŒOØ%BÐ%BÐ%BÐ%BˆDÔ"Ð"ð#ˆCå˜S‘/”/Ð!à× Ò Ñ"Ô"Ð"Ð"Ð"rA   c           
      óJ  — |                       ¦   «         | _        t          | d¦  «        sOt          t	          | j        dd| j        ¬¦  «        ¦  «        | _        t          j	        | j        d¬¦  «        | _
        | j        | j        dz  z  | _        | j
        | j        z                       t          j        ¦  «        | _        dt          j        t          j        | j        t          j        dt&          z  ¦  «        z  ¦  «        ¦  «                             ¦   «         z  | _        dS )	zcComputes the covariance matrix for each Gaussian kernel using
        covariance_factor().
        Ú_data_cho_covr   F©ÚrowvarÚbiasÚaweightsT)ÚlowerrC   N)rŒ   ÚfactorÚhasattrr   r   r    r)   Ú_data_covariancer   Úcholeskyr“   r8   r&   rI   Úfloat64r:   ÚlogÚdiagr   r   r   Úlog_detr   s    r2   r‘   z gaussian_kde._compute_covarianceE  s  € ð ×,Ò,Ñ.Ô.ˆŒå�t˜_Ñ-Ô-ð 	=Ý$.­s°4´<ÈØ49Ø8<¼ð0Fñ 0Fô 0Fñ %Gô %GˆDÔ!õ "(¤°Ô1FØ7;ð"=ñ "=ô "=ˆDÔð Ô/°$´+¸q±.Ñ@ˆŒØÔ*¨T¬[Ñ8×@Ò@ÅÄÑLÔLˆŒØ�œ¥¤¨¬Ý*,¬'°!µB±$©-¬-ñ)8ñ !9ô !9ñ :ô :ß:=º#¹%¼%ñ@ˆŒˆˆrA   c                 óÚ   — |                       ¦   «         | _        t          t          | j        dd| j        ¬¦  «        ¦  «        | _        t          j        | j        ¦  «        | j        dz  z  S )Nr   Fr”   rC   )	rŒ   r™   r   r   r    r)   r›   r   Úinvr   s    r2   Úinv_covzgaussian_kde.inv_covW  sj   € ð ×,Ò,Ñ.Ô.ˆŒÝ *­3¨t¬|ÀAØ05ÀÄð,Nñ ,Nô ,Nñ !Oô !OˆÔåŒz˜$Ô/Ñ0Ô0°4´;À±>ÑAÐArA   c                 ó,   — |                       |¦  «        S )z×
        Evaluate the estimated pdf on a provided set of points.

        Notes
        -----
        This is an alias for `gaussian_kde.evaluate`.  See the ``evaluate``
        docstring for more details.

        )r@   )r/   Úxs     r2   Úpdfzgaussian_kde.pdfc  s   € ð �}Š}˜QÑÔÐrA   c                 ó˜  — t          |¦  «        }|j        \  }}|| j        k    rG|dk    r%|| j        k    rt          || j        df¦  «        }d}nd|› d| j        › �}t	          |¦  «        ‚t          | j        |¦  «        \  }}t          |         | j        j	        | j
        dd…df         |j	        | j        |¦  «        }|dd…df         S )zT
        Evaluate the log of the estimated pdf on a provided set of points.
        r   r5   r6   Nr   )r   r#   r$   r	   r"   r7   r8   r   r    r9   r)   r:   )	r/   r¥   r;   r$   r<   r0   r=   r>   r?   s	            r2   Úlogpdfzgaussian_kde.logpdfo  sã   € õ ˜A‘”ˆàŒ|‰ˆˆ1Ø�”Š;ˆ;Ø�AŠvˆv˜!˜tœvš+˜+å  ¨$¬&°!¨Ñ5Ô5�Ø��ð9°ð 9ð 9Ø04´ð9ð 9�å  ‘o”oÐ%å.¨t¬ÀÑGÔGÑˆ�dÝ-¨dÔ3ØŒLŒN˜DœL¨¨¨¨D¨Ô1ØŒH�d”l Lñ2ô 2ˆð �a�a�a˜�dŒ|ÐrA   c                 ó„  — t          j        |¦  «        }t          j        |j        t           j        ¦  «        sd}t          |¦  «        ‚t          | j        ¦  «        }|                     ¦   «         }|||dk              z   ||dk     <   t          t          j	        |¦  «        ¦  «        t          |¦  «        k    rd}t          |¦  «        ‚|dk     ||k    z  }t          j
        |¦  «        rd||         › d|› d�}t          |¦  «        ‚| j        |         }| j        }t          ||                      ¦   «         |¬¦  «        S )a)  Return a marginal KDE distribution

        Parameters
        ----------
        dimensions : int or 1-d array_like
            The dimensions of the multivariate distribution corresponding
            with the marginal variables, that is, the indices of the dimensions
            that are being retained. The other dimensions are marginalized out.

        Returns
        -------
        marginal_kde : gaussian_kde
            An object representing the marginal distribution.

        Notes
        -----
        .. versionadded:: 1.10.0

        zaElements of `dimensions` must be integers - the indices of the marginal variables being retained.r   z,All elements of `dimensions` must be unique.zDimensions z# are invalid for a distribution in z dimensions.)r   r)   )rI   r   Ú
issubdtypeÚdtypeÚintegerr"   r+   r    ÚcopyÚuniqueÚanyr)   r   rŒ   )	r/   Ú
dimensionsÚdimsr0   r%   Úoriginal_dimsÚ	i_invalidr    r)   s	            r2   Úmarginalzgaussian_kde.marginal‡  s=  € õ* Œ}˜ZÑ(Ô(ˆåŒ}˜TœZ­¬Ñ4Ô4ð 	"ð?ˆCå˜S‘/”/Ð!å�”ÑÔˆØŸ	š	™œˆà˜T $¨¢(œ^Ñ+ˆˆT�AŠX‰å�rŒy˜‰ŒÑÔ¥3 t¡9¤9Ò,Ð,ØAˆCÝ˜S‘/”/Ð!à˜A’X $¨!¢)Ñ,ˆ	ÝŒ6�)ÑÔð 	"ð< ¨yÔ!9ð <ð <Ø,-ð<ð <ð <ˆCå˜S‘/”/Ð!à”,˜tÔ$ˆØ”,ˆå˜G¨t×/EÒ/EÑ/GÔ/GØ$+ð-ñ -ô -ð 	-rA   c                 ó‚   — 	 | j         S # t          $ r+ t          | j        ¦  «        | j        z  | _         | j         cY S w xY wr‡   )r(   ÚAttributeErrorr   r%   r   s    r2   r)   zgaussian_kde.weights¸  sN   € ð	!Ø”=Ð øÝð 	!ð 	!ð 	!Ý  ¤™LœL¨¬Ñ/ˆDŒMØ”=Ð Ð Ð ð	!øøøs   ‚	 ‰2>½>c                 ó„   — 	 | j         S # t          $ r, dt          | j        | j        ¦  «        z  | _         | j         cY S w xY w)Nr   )r,   r¶   r   r)   r   s    r2   rs   zgaussian_kde.neffÀ  sR   € ð	Ø”:ÐøÝð 	ð 	ð 	Ø�9 T¤\°4´<Ñ@Ô@Ñ@ˆDŒJØ”:ÐÐÐð	øøøs   ‚	 ‰3?¾?)NNr‡   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r3   r@   Ú__call__rT   r^   rh   ro   rz   r€   r‚   rŒ   r-   r‘   Úpropertyr£   r¦   r¨   r´   r)   rs   rˆ   rA   r2   r   r   $   s�  € € € € € ðkð kðX$1ð $1ð $1ð $1ðL&ð &ð &ðP €Hð3ð 3ð 3ðj ð  ð  ðD8Èð 8ð 8ð 8ð 8ð 8ð<0ð 0ð 0ðd!ð !ð !ð !ðF0ð 0ð 0ðAð Að Að &Ðð!ÐÔð
=#ð =#ð =#ð =#ð~@ð @ð @ð$ ð	Bð 	Bñ „Xð	Bð
 ð 
 ð 
 ðð ð ð0/-ð /-ð /-ðb ð!ð !ñ „Xð!ð ðð ñ „Xðð ð rA   c                 óÀ   — t          j        | |¦  «        }t          j        |¦  «        j        }|dk    rd}n$|dk    rd}n|dv rd}nt	          |› d|› �¦  «        ‚||fS )zÒ
    Calculates the output dtype and the "spec" (=C type name).

    This was necessary in order to deal with the fused types in the Cython
    routine `gaussian_kernel_estimate`. See gh-10824 for details.
    r}   r'   é   Údouble)é   é   zlong doublez has unexpected item size: )rI   Úcommon_typer«   Úitemsizer"   )r8   r;   r=   rÄ   r>   s        r2   r7   r7   É  s‰   € õ ”> *¨fÑ5Ô5€LÝŒx˜Ñ%Ô%Ô.€HØ�1‚}€}ØˆˆØ	�QŠˆØˆˆØ	�XÐ	Ð	ØˆˆåØÐFÐF¸HÐFÐFñô ð 	ð ˜ÐÐrA   ) Úscipyr   r   Úscipy._lib._utilr   r   Únumpyr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   rI   Ú_statsr   r   Ú_multivariater   Ú__all__r   r7   rˆ   rA   r2   ú<module>rË      sx  ðð* "Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð Ð Ð Ð ð KÐ JÐ JÐ JÐ JÐ JÐ JÐ JØ .Ð .Ð .Ð .Ð .Ð .àÐ
€ðb
ð b
ð b
ð b
ð b
ñ b
ô b
ð b
ðJð ð ð ð rA   