| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/scipy/stats/__pycache__/ |
Upload File : |
�
d�c�l � � � d Z ddlZddlZddlmZ ddlmZmZ ddlZddlm Z m
Z
mZ ddlm
Z
ddlmZ ddlmZ dd lmZ dd
lmZmZmZmZmZ ddlmZ ddlmZ dd
lmZ ddlm Z! ddl"m#Z#m$Z$m%Z%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z9 ddl:m;Z; ddlm<Z< ddl=m>Z> g d�Z?d� Z@d� ZAd� ZBd� ZCd� ZD e;d d!d"gg � � ZE e5d#� dddd$d%� d&g�'� � d�d(�� � ZF e5d)� dddd$d*� d&g�'� � d�dd+�d,�� � ZG e5d-� dddd$d.� d&g�'� � dddd/�d0�� � ZH ed1d2� � ZId�d4�ZJd5� ZKd�d7�ZLd�d8�ZMd�d9�ZNd�d:�ZOd�d;�ZPd�d<�ZQd=� ZRd>� ZS e5eSdd?� eR�@� � d�dA�� � ZTddB�dC�ZU�d dD�ZV e5dE� dF� d�G� � �ddH�� � ZW e5dI� dJ� d�G� � �ddK�� � ZX edLdM� � ZY�ddN�ZZdO� Z[ edPdQ� � Z\�ddS�Z] edTdQ� � Z^�ddU�Z_ edVdQ� � Z`�ddW�Za e5eEd�X� � ddY�dZ�� � Zb �dd]�Zcd^� Zd�dd`�Ze edadb� � Zf �dde�Zg edfdg� � Zh�d dh�Zi edidj� � Zj�d dk�Zkdl� Zl�d
dm�Zmdn� Zndo� Zo�ddp�Zp�ddq�Zqddd3dr�ds�Zr�ddt�Zs�d
du�Ztdv eju dw� � dxz ejv dx� � z dy�Zw �dd|�Zxd}� Zydejz dvd3fd~�Z{ edd�� � Z|�dd��Z}�dd��Z~�dd��Z�dd��Z� ed�dQ� � Z�d�� Z�d�� Z�ddY�d��Z�d3d��d��Z�d�� Z� e-d�dQ� � Z�d�� Z� ed�d�d�g� � Z� e;d�d!d"gg � � Z� G d�� d�e�� � Z�dRd��d��Z��dd��Z� �dd��Z�d�� Z� �dd��Z��dd��Z� G d�� d�� � Z��dd��Z�d�� Z� e;d�g d��g � � Z�e�d�ddddfd��Z�d�� Z�d�� Z�d�� Z�d�� Z� e;d�d!d"gd�g� � Z� G d�� d�e�� � Z�d�� Z�d�� Z� e5e�dd�e�d���� � �dd��� � Z�d�� Z�d�� Z�d�� Z�d�� Z�d�� Z� ed�dQ� � Z� �dd��Z�d�� Z� �dd��Z�d�� Z�d�� Z� �dd��Z��ddZ� �ddÄZ�dĄ Z� e5e�dd�e�d�d$�Ŧ � �ddƄ� � Z�ddd�d�d�d�dʜZ��dd˄Z�d̄ Z� ed�dQ� � Z��dd΄Z��ddτZ� e;d�d!d"gd�d�g� � Z�dӄ Z�dԄ Z� ed�d֦ � �ddׄ� � Z�e�Z�d Z�dل Z�dڄ Z� ed�d֦ � �ddۄ� � Z�d܄ Z� ed�d֦ � �ddބ� � Z�d߄ Z� ed�dQ� � Z� e5e�d��� � �dd�� � Z� ed�dQ� � Z� e5e�d�� � d3d��d�� � Z� ed�dQ� � Z�d� Z� ed�dQ� � Z� �d d�Zɐd!d�Zʐd"d�Zːd"d�Z̐d"d�Z�d� Z� ed�d� � Z�d� ZАdd�Zѐdd�ZҐd#dd3d��d��ZӐd$dd+�d��Z�dS (% z�
A collection of basic statistical functions for Python.
References
----------
.. [CRCProbStat2000] Zwillinger, D. and Kokoska, S. (2000). CRC Standard
Probability and Statistics Tables and Formulae. Chapman & Hall: New
York. 2000.
� N)�gcd)�
namedtuple�Counter)�array�asarray�ma)�NumpyVersion)�suppress_warnings��cdist)�
_measurements)�check_random_state�
MapWrapper�rng_integers�_rename_parameter�
_contains_nan)�linalg� )�
distributions)�
_mstats_basic)�
_find_repeats�
linregress�theilslopes�siegelslopes)�_kendall_dis�_toint64�_weightedrankedtau�_local_correlations)�make_dataclass)�_all_partitions)�!_compute_outer_prob_inside_method)�_batch_generator)�_axis_nan_policy_factory�_broadcast_concatenate)�_binary_search_for_binom_tst)�_make_tuple_bunch)�stats)�root_scalar)B�find_repeats�gmean�hmean�pmean�mode�tmean�tvar�tmin�tmax�tstd�tsem�moment�skew�kurtosis�describe�skewtest�kurtosistest�
normaltest�jarque_bera�scoreatpercentile�percentileofscore�cumfreq�relfreq�obrientransform�sem�zmap�zscore�gzscore�iqr�gstd�median_abs_deviation� sigmaclip�trimboth�trim1� trim_mean�f_oneway�pearsonr�fisher_exact� spearmanr�pointbiserialr�
kendalltau�weightedtau�multiscale_graphcorrr r r �ttest_1samp� ttest_ind�ttest_ind_from_stats� ttest_rel�kstest�ks_1samp�ks_2samp� chisquare�power_divergence�
tiecorrect�ranksums�kruskal�friedmanchisquare�rankdata�combine_pvalues�wasserstein_distance�energy_distance�
brunnermunzel�alexandergovern� expectilec � � |�t j | � � } d}nt j | � � } |}| j dk rt j | � � } | |fS �Nr ��np�ravelr �ndim�
atleast_1d)�a�axis�outaxiss �7/usr/lib/python3/dist-packages/scipy/stats/_stats_py.py�_chk_asarrayrs X sQ � ��|��H�Q�K�K������J�q�M�M�����v��{�{��M�!�����g�:�� c �6 � |�+t j | � � } t j |� � }d}n*t j | � � } t j |� � }|}| j dk rt j | � � } |j dk rt j |� � }| ||fS ri rj )ro �brp rq s rr �
_chk2_asarrayrw f s� � ��|��H�Q�K�K���H�Q�K�K������J�q�M�M���J�q�M�M�����v��{�{��M�!�����v��{�{��M�!�����a��=�rt c � � t | j � � } ||= n)# t $ r t j || j � � d�w xY wt
|� � S )z�
Given an array `a` and an integer `axis`, return the shape
of `a` with the `axis` dimension removed.
Examples
--------
>>> a = np.zeros((3, 5, 2))
>>> _shape_with_dropped_axis(a, 1)
(3, 2)
N)�list�shape�
IndexErrorrk � AxisErrorrm �tuple)ro rp �shps rr �_shape_with_dropped_axisr x s\ � � �q�w�-�-�C�3���I�I��� 3� 3� 3��l�4���(�(�d�2�3������:�:�s � �&A c �L � t | � � t |� � z
}|dk rd| z | z }|}n
| }d|z |z }g }t ||� � D ]H\ }}|dk r|}n%|dk s||k r|}nt d| � d|� d�� � �|� |� � �It |� � S )z�
Given two shapes (i.e. tuples of integers), return the shape
that would result from broadcasting two arrays with the given
shapes.
Examples
--------
>>> _broadcast_shapes((2, 1), (4, 1, 3))
(4, 2, 3)
r �r r zshapes � and � could not be broadcast together)�len�zip�
ValueError�appendr} ) �shape1�shape2�d�shp1�shp2rz �n1�n2�ns rr �_broadcast_shapesr� � s� � � �F���c�&�k�k�!�A��A�v�v��a�R�y�6�!��������A�v�����E��d�D�/�/� � ���B�
��7�7��A�A�
�1�W�W��b����A�A�� 2�v� 2� 2�F� 2� 2� 2� 3� 3�
3�
���Q�������<�<�rt c � � t | |� � }t ||� � } t ||� � }n%# t $ r t d|� d|� d�� � d�w xY w|S )a=
Given two arrays `a` and `b` and an integer `axis`, find the
shape of the broadcast result after dropping `axis` from the
shapes of `a` and `b`.
Examples
--------
>>> a = np.zeros((5, 2, 1))
>>> b = np.zeros((1, 9, 3))
>>> _broadcast_shapes_with_dropped_axis(a, b, 1)
(5, 3)
znon-axis shapes r� r� N)r r� r� )ro rv rp r� r� r~ s rr �#_broadcast_shapes_with_dropped_axisr� � s� � � $�A�t�,�,�D�#�A�t�,�,�D�9���d�+�+����� 9� 9� 9�� .�D� .� .�t� .� .� .� /� /�48� 9�9���� �Js �3 �"A�SignificanceResult� statistic�pvaluec � � | S �N� ��xs rr �<lambda>r� � � � �!� rt Tc � � | fS r� r� r� s rr r� r� � � � �1�$� rt �weights)� n_samples� n_outputs� too_small�paired�result_to_tuple�kwd_samplesc �2 � t j | |�� � } |�t j ||�� � }t j d�� � 5 t j | � � }ddd� � n# 1 swxY w Y t j t j |||�� � � � S )a� Compute the weighted geometric mean along the specified axis.
The weighted geometric mean of the array :math:`a_i` associated to weights
:math:`w_i` is:
.. math::
\exp \left( \frac{ \sum_{i=1}^n w_i \ln a_i }{ \sum_{i=1}^n w_i }
\right) \, ,
and, with equal weights, it gives:
.. math::
\sqrt[n]{ \prod_{i=1}^n a_i } \, .
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : int or None, optional
Axis along which the geometric mean is computed. Default is 0.
If None, compute over the whole array `a`.
dtype : dtype, optional
Type to which the input arrays are cast before the calculation is
performed.
weights : array_like, optional
The `weights` array must be broadcastable to the same shape as `a`.
Default is None, which gives each value a weight of 1.0.
Returns
-------
gmean : ndarray
See `dtype` parameter above.
See Also
--------
numpy.mean : Arithmetic average
numpy.average : Weighted average
hmean : Harmonic mean
References
----------
.. [1] "Weighted Geometric Mean", *Wikipedia*,
https://en.wikipedia.org/wiki/Weighted_geometric_mean.
Examples
--------
>>> from scipy.stats import gmean
>>> gmean([1, 4])
2.0
>>> gmean([1, 2, 3, 4, 5, 6, 7])
3.3800151591412964
>>> gmean([1, 4, 7], weights=[3, 1, 3])
2.80668351922014
��dtypeN�ignore��divide�rp r� )rk r �errstate�log�exp�average)ro rp r� r� �log_as rr r* r* � s� � �| �
�1�E�"�"�"�A����*�W�E�2�2�2�� ��H� %� %� %� � ���q� � ��� � � � � � � � � � ���� � � � � �6�"�*�U��w�?�?�?�@�@�@s �A%�%A)�,A)c � � | S r� r� r� s rr r� r� r� rt c � � | fS r� r� r� s rr r� r� r� rt �r� c �, � t | t j � � st j | |�� � } nY|rWt | t j j � � r"t j � | |�� � } nt j | |�� � } t j | dk � � rd|�t j ||�� � }t j d�� � 5 dt j
d| z ||�� � z cddd� � S # 1 swxY w Y dS t d� � �) a� Calculate the weighted harmonic mean along the specified axis.
The weighted harmonic mean of the array :math:`a_i` associated to weights
:math:`w_i` is:
.. math::
\frac{ \sum_{i=1}^n w_i }{ \sum_{i=1}^n \frac{w_i}{a_i} } \, ,
and, with equal weights, it gives:
.. math::
\frac{ n }{ \sum_{i=1}^n \frac{1}{a_i} } \, .
Parameters
----------
a : array_like
Input array, masked array or object that can be converted to an array.
axis : int or None, optional
Axis along which the harmonic mean is computed. Default is 0.
If None, compute over the whole array `a`.
dtype : dtype, optional
Type of the returned array and of the accumulator in which the
elements are summed. If `dtype` is not specified, it defaults to the
dtype of `a`, unless `a` has an integer `dtype` with a precision less
than that of the default platform integer. In that case, the default
platform integer is used.
weights : array_like, optional
The weights array can either be 1-D (in which case its length must be
the size of `a` along the given `axis`) or of the same shape as `a`.
Default is None, which gives each value a weight of 1.0.
.. versionadded:: 1.9
Returns
-------
hmean : ndarray
See `dtype` parameter above.
See Also
--------
numpy.mean : Arithmetic average
numpy.average : Weighted average
gmean : Geometric mean
Notes
-----
The harmonic mean is computed over a single dimension of the input
array, axis=0 by default, or all values in the array if axis=None.
float64 intermediate and return values are used for integer inputs.
References
----------
.. [1] "Weighted Harmonic Mean", *Wikipedia*,
https://en.wikipedia.org/wiki/Harmonic_mean#Weighted_harmonic_mean
.. [2] Ferger, F., "The nature and use of the harmonic mean", Journal of
the American Statistical Association, vol. 26, pp. 36-40, 1931
Examples
--------
>>> from scipy.stats import hmean
>>> hmean([1, 4])
1.6000000000000001
>>> hmean([1, 2, 3, 4, 5, 6, 7])
2.6997245179063363
>>> hmean([1, 4, 7], weights=[3, 1, 3])
1.9029126213592233
r� r Nr� r� � �?r� zHHarmonic mean only defined if all elements greater than or equal to zero)�
isinstancerk �ndarrayr r �MaskedArrayr �all�
asanyarrayr� r� r� )ro rp r� r� s rr r+ r+ sj � �T �a���$�$� +��H�Q�e�$�$�$��� � +��a���*�+�+� +���
�
�a�u�
�-�-�A�A��
�1�E�*�*�*�A� �v�a�1�f�~�~� 2����m�G�5�9�9�9�G�
�[��
)�
)�
)� I� I����C�!�G�$��H�H�H�H� I� I� I� I� I� I� I� I� I� I� I� I���� I� I� I� I� I� I� � 1� 2� 2� 2s �C:�:C>�C>c � � | S r� r� r� s rr r� r� p r� rt c � � | fS r� r� r� s rr r� r� q r� rt �rp r� r� c � � t |t t f� � st d� � �|dk rt | |||�� � S t | t
j � � st j | |�� � } nY|rWt | t
j j � � r"t
j �
| |�� � } nt j
| |�� � } t j | dk � � r�|�t j ||�� � }t j
d�� � 5 t j t j t j | |� � ||�� � d |z � � cddd� � S # 1 swxY w Y dS t d
� � �)u Calculate the weighted power mean along the specified axis.
The weighted power mean of the array :math:`a_i` associated to weights
:math:`w_i` is:
.. math::
\left( \frac{ \sum_{i=1}^n w_i a_i^p }{ \sum_{i=1}^n w_i }
\right)^{ 1 / p } \, ,
and, with equal weights, it gives:
.. math::
\left( \frac{ 1 }{ n } \sum_{i=1}^n a_i^p \right)^{ 1 / p } \, .
This mean is also called generalized mean or Hölder mean, and must not be
confused with the Kolmogorov generalized mean, also called
quasi-arithmetic mean or generalized f-mean [3]_.
Parameters
----------
a : array_like
Input array, masked array or object that can be converted to an array.
p : int or float
Exponent.
axis : int or None, optional
Axis along which the power mean is computed. Default is 0.
If None, compute over the whole array `a`.
dtype : dtype, optional
Type of the returned array and of the accumulator in which the
elements are summed. If `dtype` is not specified, it defaults to the
dtype of `a`, unless `a` has an integer `dtype` with a precision less
than that of the default platform integer. In that case, the default
platform integer is used.
weights : array_like, optional
The weights array can either be 1-D (in which case its length must be
the size of `a` along the given `axis`) or of the same shape as `a`.
Default is None, which gives each value a weight of 1.0.
Returns
-------
pmean : ndarray, see `dtype` parameter above.
Output array containing the power mean values.
See Also
--------
numpy.average : Weighted average
gmean : Geometric mean
hmean : Harmonic mean
Notes
-----
The power mean is computed over a single dimension of the input
array, ``axis=0`` by default, or all values in the array if ``axis=None``.
float64 intermediate and return values are used for integer inputs.
.. versionadded:: 1.9
References
----------
.. [1] "Generalized Mean", *Wikipedia*,
https://en.wikipedia.org/wiki/Generalized_mean
.. [2] Norris, N., "Convexity properties of generalized mean value
functions", The Annals of Mathematical Statistics, vol. 8,
pp. 118-120, 1937
.. [3] Bullen, P.S., Handbook of Means and Their Inequalities, 2003
Examples
--------
>>> from scipy.stats import pmean, hmean, gmean
>>> pmean([1, 4], 1.3)
2.639372938300652
>>> pmean([1, 2, 3, 4, 5, 6, 7], 1.3)
4.157111214492084
>>> pmean([1, 4, 7], -2, weights=[3, 1, 3])
1.4969684896631954
For p=-1, power mean is equal to harmonic mean:
>>> pmean([1, 4, 7], -1, weights=[3, 1, 3])
1.9029126213592233
>>> hmean([1, 4, 7], weights=[3, 1, 3])
1.9029126213592233
For p=0, power mean is defined as the geometric mean:
>>> pmean([1, 4, 7], 0, weights=[3, 1, 3])
2.80668351922014
>>> gmean([1, 4, 7], weights=[3, 1, 3])
2.80668351922014
z:Power mean only defined for exponent of type int or float.r r� r� Nr� r� r� r zEPower mean only defined if all elements greater than or equal to zero)r� �int�floatr� r* rk r� r r r� r r� r� r� �float_powerr� )ro �prp r� r� s rr r, r, o s� � �B �a�#�u��&�&� #�� "� #� #� #��A�v�v��Q�T���@�@�@�@��a���$�$� +��H�Q�e�$�$�$��� � +��a���*�+�+� +���
�
�a�u�
�-�-�A�A��
�1�E�*�*�*�A� �v�a�1�f�~�~� 2����m�G�5�9�9�9�G�
�[��
)�
)�
)� � ��>��
�2�>�!�Q�/�/�d�G�L�L�L��!��� � � � � � � � � � � � � ���� � � � � � �
� 1� 2� 2� 2s �A E!�!E%�(E%�
ModeResult)r- �count� propagatec �� � |�d}t j |t d�� � t j | � � } | j dk ro|�4t
t j g � � t j g � � � � S t j | ||�� � }t
||� � � � � S t | |� � \ } }t | |� � \ }}|r1|dk r+t j
| � � } t j | ||�� � S t j | j t j � � st j d t&