ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/lib/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/lib/__pycache__/histograms.cpython-311.pyc

�

�܋fA��	�~�dZddlZddlZddlZddlZddlZddlmZgd�Z	ej
ejd���ZeZ
d�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zeeeeeeeed�Zd�Zd�Zd�Zd�Zd�Zdd�Zee��dd���Z	dd�Zee��d d���Z 		dd�Z!ee!��d d���Z"dS)!z
Histogram-related functions
�N)�	overrides)�	histogram�histogramdd�histogram_bin_edges�numpy)�modulec�j�t|���|�����S)aPeak-to-peak value of x.

    This implementation avoids the problem of signed integer arrays having a
    peak-to-peak value that cannot be represented with the array's data type.
    This function returns an unsigned value for signed integer arrays.
    )�_unsigned_subtract�max�min)�xs �K/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/lib/histograms.py�_ptprs$���a�e�e�g�g�q�u�u�w�w�/�/�/�c�V�~t|��tj|j��zS)a~
    Square root histogram bin estimator.

    Bin width is inversely proportional to the data size. Used by many
    programs for its simplicity.

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    )r�np�sqrt�size�r
�ranges  r�_hist_bin_sqrtr s"��"	���7�7�R�W�Q�V�_�_�$�$rc�\�~t|��tj|j��dzzS)a
    Sturges histogram bin estimator.

    A very simplistic estimator based on the assumption of normality of
    the data. This estimator has poor performance for non-normal data,
    which becomes especially obvious for large data sets. The estimate
    depends only on size of the data.

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    ��?)rr�log2rrs  r�_hist_bin_sturgesr5s'��&	���7�7�b�g�a�f�o�o��+�,�,rc�>�~t|��d|jdzzzS)aI
    Rice histogram bin estimator.

    Another simple estimator with no normality assumption. It has better
    performance for large data than Sturges, but tends to overestimate
    the number of bins. The number of bins is proportional to the cube
    root of data size (asymptotically optimal). The estimate depends
    only on size of the data.

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    �@�UUUUUU�?)rrrs  r�_hist_bin_ricerLs$��(	���7�7�c�A�F�w�/�/�0�0rc�h�~dtjdzz|jzdztj|��zS)a�
    Scott histogram bin estimator.

    The binwidth is proportional to the standard deviation of the data
    and inversely proportional to the cube root of data size
    (asymptotically optimal).

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    g8@��?r)r�pir�stdrs  r�_hist_bin_scottr$ds1��$	��2�5�#�:����&�)�4�r�v�a�y�y�@�@rc�R������j�t�����dks�dkrdS����fd�}tdtt	j�������}t
td|dz��|���}||krtj	dtd����|zS)	a6
    Histogram bin estimator based on minimizing the estimated integrated squared error (ISE).

    The number of bins is chosen by minimizing the estimated ISE against the unknown true distribution.
    The ISE is estimated using cross-validation and can be regarded as a generalization of Scott's rule.
    https://en.wikipedia.org/wiki/Histogram#Scott.27s_normal_reference_rule

    This paper by Stone appears to be the origination of this rule.
    http://digitalassets.lib.berkeley.edu/sdtr/ucb/text/34.pdf

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.
    range : (float, float)
        The lower and upper range of the bins.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    �rc����|z}tj�|����d�z}d�dz|�|��zz
|zS)N)�binsrr�r&)rr�dot)�nbins�hh�p_k�n�ptp_xrr
s   ����r�jhatz_hist_bin_stone.<locals>.jhat�sO���
�U�]���l�1�5��6�6�6�q�9�A�=���Q��U�c�g�g�c�l�l�*�*�b�0�0r�d)�keyz/The number of bins estimated may be suboptimal.���
stacklevel)rrr�intrrr�_range�warnings�warn�RuntimeWarning)r
rr0�nbins_upper_boundr+r.r/s``   @@r�_hist_bin_stoner<zs�������0	
��A���G�G�E��A�v�v��!����q�1�1�1�1�1�1�1�1�
�C��R�W�Q�Z�Z���1�1����q�+�a�/�0�0�d�;�;�;�E��!�!�!��
�G�$��	4�	4�	4�	4��5�=�rc��~|jdkr�tjd|jdz
z|jdz|jdzzz��}tj|��}|dkr�|tj|��z
}tj|||��tj|d|��tj|��}t|��dtj|j��ztjdtj	|��|zz��zzSdS)a�
    Doane's histogram bin estimator.

    Improved version of Sturges' formula which works better for
    non-normal data. See
    stats.stackexchange.com/questions/55134/doanes-formula-for-histogram-binning

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    r)g@rr3g)
rrrr#�mean�true_divide�powerrr�absolute)r
r�sg1�sigma�temp�g1s      r�_hist_bin_doanerF�s���$	��v��z�z��g�c�Q�V�a�Z�(�Q�V�c�\�a�f�q�j�,I�J�K�K����q�	�	���3�;�;��r�w�q�z�z�>�D��N�4���-�-�-��H�T�1�d�#�#�#������B���7�7�c�B�G�A�F�O�O�3�$&�G�C�"�+�b�/�/�C�2G�,G�$H�$H�I�J�
J��3rc�j�~tjtj|ddg���}d|z|jdzzS)a=
    The Freedman-Diaconis histogram bin estimator.

    The Freedman-Diaconis rule uses interquartile range (IQR) to
    estimate binwidth. It is considered a variation of the Scott rule
    with more robustness as the IQR is less affected by outliers than
    the standard deviation. However, the IQR depends on fewer points
    than the standard deviation, so it is less accurate, especially for
    long tailed distributions.

    If the IQR is 0, this function returns 0 for the bin width.
    Binwidth is inversely proportional to the cube root of data size
    (asymptotically optimal).

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.
    �K�rgUUUUUUտ)r�subtract�
percentiler)r
r�iqrs   r�_hist_bin_fdrM�s9��2	�
�+�r�}�Q��R��1�1�
2�C���9�q�v�*�-�-�-rc�l�t||��}t||��}~|rt||��S|S)a�
    Histogram bin estimator that uses the minimum width of the
    Freedman-Diaconis and Sturges estimators if the FD bin width is non-zero.
    If the bin width from the FD estimator is 0, the Sturges estimator is used.

    The FD estimator is usually the most robust method, but its width
    estimate tends to be too large for small `x` and bad for data with limited
    variance. The Sturges estimator is quite good for small (<1000) datasets
    and is the default in the R language. This method gives good off-the-shelf
    behaviour.

    .. versionchanged:: 1.15.0
    If there is limited variance the IQR can be 0, which results in the
    FD bin width being 0 too. This is not a valid bin width, so
    ``np.histogram_bin_edges`` chooses 1 bin instead, which may not be optimal.
    If the IQR is 0, it's unlikely any variance-based estimators will be of
    use, so we revert to the Sturges estimator, which only uses the size of the
    dataset in its calculation.

    Parameters
    ----------
    x : array_like
        Input data that is to be histogrammed, trimmed to range. May not
        be empty.

    Returns
    -------
    h : An estimate of the optimal bin width for the given data.

    See Also
    --------
    _hist_bin_fd, _hist_bin_sturges
    )rMrr)r
r�fd_bw�
sturges_bws    r�_hist_bin_autorQ�sF��D
��E�"�"�E�"�1�e�,�,�J�
����5�*�%�%�%��r)�stone�auto�doane�fd�rice�scottr�sturgesc���tj|��}|jtjkr^t	jd�|jtj��td���|�	tj��}|�Gtj|��}|j
|j
krtd���|���}|���}||fS)z: Check a and weights have matching shapes, and ravel both z1Converting input from {} to {} for compatibility.r3r4Nz(weights should have the same shape as a.)
r�asarray�dtype�bool_r8r9�format�uint8r:�astype�shape�
ValueError�ravel)�a�weightss  r�_ravel_and_check_weightsres���
�
�1�
�
�A�	�w�"�(����
�I��v�a�g�r�x�0�0�$��	4�	4�	4�	4�
�H�H�R�X�������*�W�%�%���=�A�G�#�#��:�<�<�
<��-�-�/�/��	���	�	�A��g�:�rc��|�f|\}}||krtd���tj|��rtj|��s#td�||�����n�|jdkrd\}}ns|���|���}}tj|��rtj|��s#td�||�����||kr
|dz
}|dz}||fS)z^
    Determine the outer bin edges to use, from either the data or the range
    argument
    Nz/max must be larger than min in range parameter.z(supplied range of [{}, {}] is not finiter)rr&z,autodetected range of [{}, {}] is not finiter!)rar�isfiniter]rrr)rcr�
first_edge�	last_edges    r�_get_outer_edgesrj0s5��

�� %��
�I��	�!�!��A�C�C�
C���J�'�'�	Z�B�K�	�,B�,B�	Z��:�A�A�*�i�X�X�Z�Z�
Z�	Z�
��1��� $��
�I�I� !����������I�
���J�'�'�	^�B�K�	�,B�,B�	^��>�E�E�j�R[�\�\�^�^�
^��Y����#�%�
���O�	��y� � rc
��tjtjtjtjtjtjtjtjtj	tj
i}tj||��}	||j}tj
||d|���S#t$rtj
|||���cYSwxYw)z�
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    �unsafe)�castingr[�r[)r�byte�ubyte�short�ushort�intc�uintc�int_�uint�longlong�	ulonglong�result_type�typerJ�KeyError)rc�b�signed_to_unsigned�dts    rr
r
Ns���	����
��"�)�
����
����
��R�\���
���1�	�	�B�=�
���
(���{�1�a���<�<�<�<���+�+�+��{�1�a�r�*�*�*�*�*�*�+���s�
B,�,!C�Cc���d}d}t|t��r�|}|tvr"td�|�����|�td���t
||��\}}|�6||k}	|	||kz}	tj�	|	��s||	}|j
dkrd}�n<t||||f��}
|
r3ttjt||��|
z����}n�d}n�tj|��dkra	tj|��}n"#t
$r}td��|�d}~wwxYw|dkrtd���t
||��\}}nstj|��dkrLtj|��}tj|dd�|dd�k��rtd	���ntd
���|�rtj|||��}tj|tj��rtj|t,��}tj|||dzd|���}||||ffS|dfS)
a
    Computes the bins used internally by `histogram`.

    Parameters
    ==========
    a : ndarray
        Ravelled data array
    bins, range
        Forwarded arguments from `histogram`.
    weights : ndarray, optional
        Ravelled weights array, or None

    Returns
    =======
    bin_edges : ndarray
        Array of bin edges
    uniform_bins : (Number, Number, int):
        The upper bound, lowerbound, and number of bins, used in the optimized
        implementation of `histogram` that works on uniform bins.
    Nz({!r} is not a valid estimator for `bins`zMAutomated estimation of the number of bins is not supported for weighted datarr&z0`bins` must be an integer, a string, or an arrayz(`bins` must be positive, when an integer���z1`bins` must increase monotonically, when an arrayz `bins` must be 1d, when an arrayT)�endpointr[)�
isinstance�str�_hist_bin_selectorsrar]�	TypeErrorrjr�logical_and�reducerr6�ceilr
�ndim�operator�indexrZ�anyry�
issubdtype�integer�float�linspace)
rcr(rrd�n_equal_bins�	bin_edges�bin_namerhri�keep�width�e�bin_types
             r�_get_bin_edgesr�hs���,�L��I��$����2=����.�.�.��:�A�A�(�K�K�M�M�
M����F�G�G�
G�!1��E� :� :��
�I�����O�D��Q�)�^�$�D��>�(�(��.�.�
��d�G���6�Q�;�;��L�L�(��1�!�j�)�5L�M�M�E��
!�"�2�7�+=�i��+T�+T�W\�+\�#]�#]�^�^��� !���	�����!�	�	�	K�#�>�$�/�/�L�L���	K�	K�	K��B�D�D�IJ�
K�����	K�����!����G�H�H�H� 0��E� :� :��
�I�I�	�����!�	�	��J�t�$�$�	�
�6�)�C�R�C�.�9�Q�R�R�=�0�1�1�	E��C�E�E�
E�	E�
�;�<�<�<����>�*�i��;�;��
�=��2�:�.�.�	7��~�h��6�6�H��K��	�<�!�#3���+�+�+�	��:�y�,�?�?�?��$��s�D0�0
E�:E
�
Ec��tj|�|dd�d��|�|dd�d��f��S)z�
    Like `searchsorted`, but where the last item in `v` is placed on the right.

    In the context of a histogram, this makes the last bin edge inclusive
    Nr��left�right)r�concatenate�searchsorted)rc�vs  r�_search_sorted_inclusiver��sO���>�	���q��"��v�v�&�&�	���q����v�w�'�'����rc��|||fS�N�)rcr(rrds    r�_histogram_bin_edges_dispatcherr��s��
�t�W��r�
c�V�t||��\}}t||||��\}}|S)aY
    Function to calculate only the edges of the bins used by the `histogram`
    function.

    Parameters
    ----------
    a : array_like
        Input data. The histogram is computed over the flattened array.
    bins : int or sequence of scalars or str, optional
        If `bins` is an int, it defines the number of equal-width
        bins in the given range (10, by default). If `bins` is a
        sequence, it defines the bin edges, including the rightmost
        edge, allowing for non-uniform bin widths.

        If `bins` is a string from the list below, `histogram_bin_edges` will use
        the method chosen to calculate the optimal bin width and
        consequently the number of bins (see `Notes` for more detail on
        the estimators) from the data that falls within the requested
        range. While the bin width will be optimal for the actual data
        in the range, the number of bins will be computed to fill the
        entire range, including the empty portions. For visualisation,
        using the 'auto' option is suggested. Weighted data is not
        supported for automated bin size selection.

        'auto'
            Maximum of the 'sturges' and 'fd' estimators. Provides good
            all around performance.

        'fd' (Freedman Diaconis Estimator)
            Robust (resilient to outliers) estimator that takes into
            account data variability and data size.

        'doane'
            An improved version of Sturges' estimator that works better
            with non-normal datasets.

        'scott'
            Less robust estimator that takes into account data variability
            and data size.

        'stone'
            Estimator based on leave-one-out cross-validation estimate of
            the integrated squared error. Can be regarded as a generalization
            of Scott's rule.

        'rice'
            Estimator does not take variability into account, only data
            size. Commonly overestimates number of bins required.

        'sturges'
            R's default method, only accounts for data size. Only
            optimal for gaussian data and underestimates number of bins
            for large non-gaussian datasets.

        'sqrt'
            Square root (of data size) estimator, used by Excel and
            other programs for its speed and simplicity.

    range : (float, float), optional
        The lower and upper range of the bins.  If not provided, range
        is simply ``(a.min(), a.max())``.  Values outside the range are
        ignored. The first element of the range must be less than or
        equal to the second. `range` affects the automatic bin
        computation as well. While bin width is computed to be optimal
        based on the actual data within `range`, the bin count will fill
        the entire range including portions containing no data.

    weights : array_like, optional
        An array of weights, of the same shape as `a`.  Each value in
        `a` only contributes its associated weight towards the bin count
        (instead of 1). This is currently not used by any of the bin estimators,
        but may be in the future.

    Returns
    -------
    bin_edges : array of dtype float
        The edges to pass into `histogram`

    See Also
    --------
    histogram

    Notes
    -----
    The methods to estimate the optimal number of bins are well founded
    in literature, and are inspired by the choices R provides for
    histogram visualisation. Note that having the number of bins
    proportional to :math:`n^{1/3}` is asymptotically optimal, which is
    why it appears in most estimators. These are simply plug-in methods
    that give good starting points for number of bins. In the equations
    below, :math:`h` is the binwidth and :math:`n_h` is the number of
    bins. All estimators that compute bin counts are recast to bin width
    using the `ptp` of the data. The final bin count is obtained from
    ``np.round(np.ceil(range / h))``. The final bin width is often less
    than what is returned by the estimators below.

    'auto' (maximum of the 'sturges' and 'fd' estimators)
        A compromise to get a good value. For small datasets the Sturges
        value will usually be chosen, while larger datasets will usually
        default to FD.  Avoids the overly conservative behaviour of FD
        and Sturges for small and large datasets respectively.
        Switchover point is usually :math:`a.size \approx 1000`.

    'fd' (Freedman Diaconis Estimator)
        .. math:: h = 2 \frac{IQR}{n^{1/3}}

        The binwidth is proportional to the interquartile range (IQR)
        and inversely proportional to cube root of a.size. Can be too
        conservative for small datasets, but is quite good for large
        datasets. The IQR is very robust to outliers.

    'scott'
        .. math:: h = \sigma \sqrt[3]{\frac{24 \sqrt{\pi}}{n}}

        The binwidth is proportional to the standard deviation of the
        data and inversely proportional to cube root of ``x.size``. Can
        be too conservative for small datasets, but is quite good for
        large datasets. The standard deviation is not very robust to
        outliers. Values are very similar to the Freedman-Diaconis
        estimator in the absence of outliers.

    'rice'
        .. math:: n_h = 2n^{1/3}

        The number of bins is only proportional to cube root of
        ``a.size``. It tends to overestimate the number of bins and it
        does not take into account data variability.

    'sturges'
        .. math:: n_h = \log _{2}(n) + 1

        The number of bins is the base 2 log of ``a.size``.  This
        estimator assumes normality of data and is too conservative for
        larger, non-normal datasets. This is the default method in R's
        ``hist`` method.

    'doane'
        .. math:: n_h = 1 + \log_{2}(n) +
                        \log_{2}\left(1 + \frac{|g_1|}{\sigma_{g_1}}\right)

            g_1 = mean\left[\left(\frac{x - \mu}{\sigma}\right)^3\right]

            \sigma_{g_1} = \sqrt{\frac{6(n - 2)}{(n + 1)(n + 3)}}

        An improved version of Sturges' formula that produces better
        estimates for non-normal datasets. This estimator attempts to
        account for the skew of the data.

    'sqrt'
        .. math:: n_h = \sqrt n

        The simplest and fastest estimator. Only takes into account the
        data size.

    Examples
    --------
    >>> arr = np.array([0, 0, 0, 1, 2, 3, 3, 4, 5])
    >>> np.histogram_bin_edges(arr, bins='auto', range=(0, 1))
    array([0.  , 0.25, 0.5 , 0.75, 1.  ])
    >>> np.histogram_bin_edges(arr, bins=2)
    array([0. , 2.5, 5. ])

    For consistency with histogram, an array of pre-computed bins is
    passed through unmodified:

    >>> np.histogram_bin_edges(arr, [1, 2])
    array([1, 2])

    This function allows one set of bins to be computed, and reused across
    multiple histograms:

    >>> shared_bins = np.histogram_bin_edges(arr, bins='auto')
    >>> shared_bins
    array([0., 1., 2., 3., 4., 5.])

    >>> group_id = np.array([0, 1, 1, 0, 1, 1, 0, 1, 1])
    >>> hist_0, _ = np.histogram(arr[group_id == 0], bins=shared_bins)
    >>> hist_1, _ = np.histogram(arr[group_id == 1], bins=shared_bins)

    >>> hist_0; hist_1
    array([1, 1, 0, 1, 0])
    array([2, 0, 1, 1, 2])

    Which gives more easily comparable results than using separate bins for
    each histogram:

    >>> hist_0, bins_0 = np.histogram(arr[group_id == 0], bins='auto')
    >>> hist_1, bins_1 = np.histogram(arr[group_id == 1], bins='auto')
    >>> hist_0; hist_1
    array([1, 1, 1])
    array([2, 1, 1, 2])
    >>> bins_0; bins_1
    array([0., 1., 2., 3.])
    array([0.  , 1.25, 2.5 , 3.75, 5.  ])

    )rer�)rcr(rrdr��_s      rrr�s5��L*�!�W�5�5�J�A�w�!�!�T�5�'�:�:�L�I�q��rc��|||fSr�r�)rcr(r�densityrds     r�_histogram_dispatcherr��s��
�t�W��rc�"�t||��\}}t||||��\}}|�tjtj��}n|j}d}|dupBtj|jtj��ptj|jt��}	|���|	�r�|\}
}}tj||��}
|t||
��z}tdt|��|��D�]�}||||z�}|�d}n
||||z�}||
k}|||kz}tj�
|��s||}|�||}|�|jd���}t||
��|z}|�tj��}|||kxxdzcc<|||k}||xxdzcc<|||dzk||dz
kz}||xxdz
cc<|jdkrV|
xjtj||j|���z
c_|
xjtj||j|���z
c_��j|
tj|||����|��z
}
����n<tj|j|��}|�Ttdt|��|��D]4}tj||||z���}|t+||��z
}�5n�tjd|�	��}tdt|��|��D]�}||||z�}||||z�}tj|��}||}||}tj||���f��}t+||��}|||z
}��tj|��}
|rHtjtj|��t6��}|
|z|
���z|fS|
|fS)
a�
    Compute the histogram of a dataset.

    Parameters
    ----------
    a : array_like
        Input data. The histogram is computed over the flattened array.
    bins : int or sequence of scalars or str, optional
        If `bins` is an int, it defines the number of equal-width
        bins in the given range (10, by default). If `bins` is a
        sequence, it defines a monotonically increasing array of bin edges,
        including the rightmost edge, allowing for non-uniform bin widths.

        .. versionadded:: 1.11.0

        If `bins` is a string, it defines the method used to calculate the
        optimal bin width, as defined by `histogram_bin_edges`.

    range : (float, float), optional
        The lower and upper range of the bins.  If not provided, range
        is simply ``(a.min(), a.max())``.  Values outside the range are
        ignored. The first element of the range must be less than or
        equal to the second. `range` affects the automatic bin
        computation as well. While bin width is computed to be optimal
        based on the actual data within `range`, the bin count will fill
        the entire range including portions containing no data.
    weights : array_like, optional
        An array of weights, of the same shape as `a`.  Each value in
        `a` only contributes its associated weight towards the bin count
        (instead of 1). If `density` is True, the weights are
        normalized, so that the integral of the density over the range
        remains 1.
    density : bool, optional
        If ``False``, the result will contain the number of samples in
        each bin. If ``True``, the result is the value of the
        probability *density* function at the bin, normalized such that
        the *integral* over the range is 1. Note that the sum of the
        histogram values will not be equal to 1 unless bins of unity
        width are chosen; it is not a probability *mass* function.

    Returns
    -------
    hist : array
        The values of the histogram. See `density` and `weights` for a
        description of the possible semantics.
    bin_edges : array of dtype float
        Return the bin edges ``(length(hist)+1)``.


    See Also
    --------
    histogramdd, bincount, searchsorted, digitize, histogram_bin_edges

    Notes
    -----
    All but the last (righthand-most) bin is half-open.  In other words,
    if `bins` is::

      [1, 2, 3, 4]

    then the first bin is ``[1, 2)`` (including 1, but excluding 2) and
    the second ``[2, 3)``.  The last bin, however, is ``[3, 4]``, which
    *includes* 4.


    Examples
    --------
    >>> np.histogram([1, 2, 1], bins=[0, 1, 2, 3])
    (array([0, 2, 1]), array([0, 1, 2, 3]))
    >>> np.histogram(np.arange(4), bins=np.arange(5), density=True)
    (array([0.25, 0.25, 0.25, 0.25]), array([0, 1, 2, 3, 4]))
    >>> np.histogram([[1, 2, 1], [1, 0, 1]], bins=[0,1,2,3])
    (array([1, 4, 1]), array([0, 1, 2, 3]))

    >>> a = np.arange(5)
    >>> hist, bin_edges = np.histogram(a, density=True)
    >>> hist
    array([0.5, 0. , 0.5, 0. , 0. , 0.5, 0. , 0.5, 0. , 0.5])
    >>> hist.sum()
    2.4999999999999996
    >>> np.sum(hist * np.diff(bin_edges))
    1.0

    .. versionadded:: 1.11.0

    Automated Bin Selection Methods example, using 2 peak random data
    with 2000 points:

    >>> import matplotlib.pyplot as plt
    >>> rng = np.random.RandomState(10)  # deterministic random data
    >>> a = np.hstack((rng.normal(size=1000),
    ...                rng.normal(loc=5, scale=2, size=1000)))
    >>> _ = plt.hist(a, bins='auto')  # arguments are passed to np.histogram
    >>> plt.title("Histogram with 'auto' bins")
    Text(0.5, 1.0, "Histogram with 'auto' bins")
    >>> plt.show()

    NirF)�copyr&�c)rd�	minlengthrn)rer�rr[�intp�can_cast�double�complex�zerosr
r7�lenr�r�r_�kind�real�bincount�imagr`�sortr��argsortr��cumsum�diff�arrayr��sum)rcr(rr�rdr��uniform_bins�ntype�BLOCK�simple_weightsrhrir�r.�norm�i�tmp_a�tmp_wr��	f_indices�indices�	decrement�	increment�cum_n�sa�zero�
sorting_index�sw�cw�	bin_index�dbs                               rrr�sr��H*�!�W�5�5�J�A�w�,�Q��e�W�E�E��I�|�������!�!����
��
�E�
	�4��	,�
��G�M�2�9�-�-�	,�
��G�M�7�+�+����N��/;�+�
�I�|�
�H�\�5�)�)���0��J�G�G�G����3�q�6�6�5�)�)�+	G�+	G�A��a��%��i�L�E��������!�e�)��,���Z�'�D��U�i�'�(�D��>�(�(��.�.�
(��d����$�!�$�K�E�
�L�L���u�L�=�=�E�+�5�*�=�=��D�I��&�&�r�w�/�/�G��G�|�+�,�,�,��1�,�,�,��	�'� 2�2�I��I����!�#�����9�W�q�[�#9�9�#�|�a�'7�7�9�I��I����!�#�����z�S� � ����"�+�g�u�z�0<�>�>�>�>������"�+�g�u�z�0<�>�>�>�>�����R�[��%�+7�9�9�9�9?�����G���U+	G�\����%�0�0���?��A�s�1�v�v�u�-�-�
A�
A���W�Q�q��5��y�\�*�*���1�"�i�@�@�@���
A��8�A�U�+�+�+�D��A�s�1�v�v�u�-�-�
'�
'���!�A�e�G�)�����!�E�'�	�*�� "�
�5� 1� 1�
��=�)���=�)���^�T�2�9�9�;�;�$7�8�8��4�R��C�C�	���I��&����G�E�N�N���'�
�X�b�g�i�(�(�%�
0�
0����t�A�E�E�G�G�|�Y�&�&��i�<�rc#�K�t|d��r|V�n|Ed{V��tjt��5|Ed{V��ddd��n#1swxYwY|V�dS)Nr`)�hasattr�
contextlib�suppressr�)�sampler(rr�rds     r�_histogramdd_dispatcherr�xs������v�w�����������������	�	�Y�	'�	'�����������������������������
�M�M�M�M�Ms�	A�A�Ac�����	�j\}}n:#ttf$r&tj���j��j\}}YnwxYwtj|tj��}|dgz�|dgz}|�tj|��}	t|��}	|	|krtd���n#t$r	||gz}YnwxYw|�d|z}n"t|��|krtd���t|��D�]�}
tj||
��dkr�||
dkr"td�
|
�����t�dd�|
f||
��\}}	tj||
��}
n5#t$r(}td�
|
����|�d}~wwxYwtj|||
dz���|
<n�tj||
��dkrttj||
���|
<tj�|
dd	��|
dd�k��r"td
�
|
�����n"td�
|
�����t�|
��dz||
<tj�|
��||
<���t)��fd�t|��D����}t|��D]4}
�dd�|
f�|
d	k}||
|xxdzcc<�5tj||��}tj|||����
��}|�|��}|�t4d���}|t7dd	��fz}||}|rq|���}t|��D]H}
tj|t<��}||
dz
||
<|||
�|��z}�I||z}|j|dz
k���rt?d���|�fS)ab	
    Compute the multidimensional histogram of some data.

    Parameters
    ----------
    sample : (N, D) array, or (N, D) array_like
        The data to be histogrammed.

        Note the unusual interpretation of sample when an array_like:

        * When an array, each row is a coordinate in a D-dimensional space -
          such as ``histogramdd(np.array([p1, p2, p3]))``.
        * When an array_like, each element is the list of values for single
          coordinate - such as ``histogramdd((X, Y, Z))``.

        The first form should be preferred.

    bins : sequence or int, optional
        The bin specification:

        * A sequence of arrays describing the monotonically increasing bin
          edges along each dimension.
        * The number of bins for each dimension (nx, ny, ... =bins)
        * The number of bins for all dimensions (nx=ny=...=bins).

    range : sequence, optional
        A sequence of length D, each an optional (lower, upper) tuple giving
        the outer bin edges to be used if the edges are not given explicitly in
        `bins`.
        An entry of None in the sequence results in the minimum and maximum
        values being used for the corresponding dimension.
        The default, None, is equivalent to passing a tuple of D None values.
    density : bool, optional
        If False, the default, returns the number of samples in each bin.
        If True, returns the probability *density* function at the bin,
        ``bin_count / sample_count / bin_volume``.
    weights : (N,) array_like, optional
        An array of values `w_i` weighing each sample `(x_i, y_i, z_i, ...)`.
        Weights are normalized to 1 if density is True. If density is False,
        the values of the returned histogram are equal to the sum of the
        weights belonging to the samples falling into each bin.

    Returns
    -------
    H : ndarray
        The multidimensional histogram of sample x. See density and weights
        for the different possible semantics.
    edges : list
        A list of D arrays describing the bin edges for each dimension.

    See Also
    --------
    histogram: 1-D histogram
    histogram2d: 2-D histogram

    Examples
    --------
    >>> r = np.random.randn(100,3)
    >>> H, edges = np.histogramdd(r, bins = (5, 8, 4))
    >>> H.shape, edges[0].size, edges[1].size, edges[2].size
    ((5, 8, 4), 6, 9, 5)

    NzEThe dimension of bins must be equal to the dimension of the sample x.r�z0range argument must have one entry per dimensionrr&z,`bins[{}]` must be positive, when an integerz,`bins[{}]` must be an integer, when a scalarr�z:`bins[{}]` must be monotonically increasing, when an arrayz'`bins[{}]` must be a scalar or 1d arrayc3�f�K�|]+}tj�|�dd�|fd���V��,dS)Nr�)�side)rr�)�.0r��edgesr�s  ��r�	<genexpr>zhistogramdd.<locals>.<genexpr>sZ�������
�	���a��&����A��,�W�=�=�=������r)r��safe)rmr)zInternal Shape Error) r`�AttributeErrorrar�
atleast_2d�T�emptyr�rZr�r�r7r�r]rjr�r�r�r�r��tuple�ravel_multi_indexr��prod�reshaper_r��slicer��onesr6�RuntimeError)r�r(rr�rd�N�D�nbin�dedges�Mr��smin�smaxr.r��Ncount�on_edge�xy�hist�core�sr`r�s`                     @rrr�s�����D��|���1�1���J�'������v�&�&�(���|���1�1�1�����
�8�A�r�w���D�
�t�f�H�E�
��v�X�F����*�W�%�%�����I�I����6�6�����
��������$��x��������

�}��!����	�U���q����K�L�L�L��A�Y�Y�&�&��
�7�4��7���q� � ��A�w��{�{� �B�I�I�!�L�L�N�N�N�)�&����1��+�u�Q�x�@�@�J�D�$�
��N�4��7�+�+�����
�
�
��?�F�F�q�I�I���������
����
�{�4��q�1�u�5�5�E�!�H�H�
�W�T�!�W�
�
��
"�
"��z�$�q�'�*�*�E�!�H��v�e�A�h�s��s�m�e�A�h�q�r�r�l�2�3�3�
 � �P��V�A�Y�Y� � � �
 �
�9�@�@��C�C�E�E�
E��e�A�h�-�-�!�#��Q���G�E�!�H�%�%��q�	�	����������������F��A�Y�Y� � ���!�!�!�Q�$�<�5��8�B�<�/���q�	�'����a������
�	�f�d�	+�	+�B��;�r�7�d�i�i�k�k�:�:�:�D��<�<����D��;�;�u�f�;�-�-�D�
�e�A�r�l�l�_��D���:�D����H�H�J�J������	3�	3�A��G�A�s�O�O�E��A�w��{�E�!�H��&��)�+�+�E�2�2�2�D�D���	���
�d�Q�h��#�#�%�%�$��"�$�$�	$���;�s9�
�4A�A�$B0�0C�C�2F
�
F?�#F:�:F?)NNN)r�NN)NNNN)r�NNN)#�__doc__r��	functoolsr�r8rr�
numpy.corer�__all__�partial�array_function_dispatchrr7rrrrr$r<rFrMrQr�rerjr
r�r�r�rr�rr�rr�rr�<module>r�s|������������������������ � � � � � �
=�
=�
=��+�)�+�
�%�g�7�7�7��

��0�0�0�%�%�%�*-�-�-�.1�1�1�0A�A�A�,'�'�'�T � � �F.�.�.�<)�)�)�X!0�-� /�)�-� /�-�"3�5�5�����*!�!�!�<=�=�=�4[�[�[�|	�	�	�������8�9�9�G�G�G�:�9�G�V9=�����
��.�/�/�N�N�N�0�/�N�bDH�$(�������0�1�1�j�j�j�2�1�j�j�jr

Zerion Mini Shell 1.0