| 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�cgI � �� � d dl mZ d dlZd dlZd dlmZ d dlZd dlmZm Z m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlm Z d dlm!Z! d dl"m#Z# d dl$m%Z%m&Z& d d
l'm(Z( d dl'm)Z) d dl*m+Z+ d d
l)m,Z,m-Z-m.Z. d dl/m0Z0 d dl'm1Z1 d dl2m3Z3 d dl4m5Z5 d dl6m7Z7 ddl8m9Z9 g d�Z: edd� � Z; edd� � Z< edd� � Z=d�d�Z>d� Z? e7d� d� d d�� � d�d �� � Z@ e7d!� d"� d d�� � d�d#�� � ZAd$� ZBd�d&�ZCd'� ZDd�d+�ZEd�d.�ZFd�d0�ZGd1� ZHd2� ZId�d3�ZJd�d5�ZKd�d6�ZLd�d7�ZMd�d8�ZNd9� ZOd:� ZPd�d<�ZQd�d=�ZR ed>d?� � ZSd@� ZT eg dA�� � ZU eg dB�� � ZV eg dC�� � ZW eg dD�� � ZX e#dEg dF�dGg� � ZYd�dH�ZZdI� Z[dJ� Z\ e#dKg dL�g � � Z]d�dM�Z^ edNd?� � Z_ G dO� dP� � Z` e`� � Zad�dR�Zb edSd?� � ZcdT� Zd edUd?� � ZedVdWdX�dY�Zf e9dZ� � d�d\�� � Zgd]� Zh ed^d?� � ZidVdWdX�d_�Zj e7d`� dad �b� � d�de�� � Zkd�df�Zl e#dgdhdig� � Zmdj� Znd�dk�Zodl� Zp e%dmdn� � e7eod%do� enep�p� � d�ds�� � � � Zq e#dtg du�g � � Zrdvd%d dwdx�dy�Zsd�dz�Ztdez d ddwfd{�Zudez d ddwfd|�Zvdez d ddwfd*d}�d~�Zw G d� d�� � Zxd d%d��d��ZydS )�� )�annotationsN)�
namedtuple)�isscalar�r_�log�around�unique�asarray�zeros�arange�sort�amin�amax�
atleast_1d�sqrt�array�compress�pi�exp�ravel�
count_nonzero�sin�cos�arctan2�hypot)�optimize)�special)�_make_tuple_bunch)�_rename_parameter�
_contains_nan� )�_statlib)� _stats_py)� FitResult)�find_repeats�_normtest_finish�SignificanceResult)�chi2_contingency)�
distributions)�
rv_generic)�_get_wilcoxon_distr)�_axis_nan_policy_factory� )�_deprecated)�mvsdist� bayes_mvs�kstat�kstatvar�probplot�ppcc_max� ppcc_plot�
boxcox_llf�boxcox�boxcox_normmax�boxcox_normplot�shapiro�anderson�ansari�bartlett�levene�
binom_test�fligner�mood�wilcoxon�median_test�circmean�circvar�circstd�anderson_ksamp�yeojohnson_llf�
yeojohnson�yeojohnson_normmax�yeojohnson_normplot�directional_stats�Mean)� statistic�minmax�Variance�Std_dev��������?c � � t | � � \ }}}|dk s|dk rt d|z � � �t |� � � |� |� � � � }t |� � � |� |� � � � }t
|� � � |� |� � � � }|||fS )a-
Bayesian confidence intervals for the mean, var, and std.
Parameters
----------
data : array_like
Input data, if multi-dimensional it is flattened to 1-D by `bayes_mvs`.
Requires 2 or more data points.
alpha : float, optional
Probability that the returned confidence interval contains
the true parameter.
Returns
-------
mean_cntr, var_cntr, std_cntr : tuple
The three results are for the mean, variance and standard deviation,
respectively. Each result is a tuple of the form::
(center, (lower, upper))
with `center` the mean of the conditional pdf of the value given the
data, and `(lower, upper)` a confidence interval, centered on the
median, containing the estimate to a probability ``alpha``.
See Also
--------
mvsdist
Notes
-----
Each tuple of mean, variance, and standard deviation estimates represent
the (center, (lower, upper)) with center the mean of the conditional pdf
of the value given the data and (lower, upper) is a confidence interval
centered on the median, containing the estimate to a probability
``alpha``.
Converts data to 1-D and assumes all data has the same mean and variance.
Uses Jeffrey's prior for variance and std.
Equivalent to ``tuple((x.mean(), x.interval(alpha)) for x in mvsdist(dat))``
References
----------
T.E. Oliphant, "A Bayesian perspective on estimating mean, variance, and
standard-deviation from data", https://scholarsarchive.byu.edu/facpub/278,
2006.
Examples
--------
First a basic example to demonstrate the outputs:
>>> from scipy import stats
>>> data = [6, 9, 12, 7, 8, 8, 13]
>>> mean, var, std = stats.bayes_mvs(data)
>>> mean
Mean(statistic=9.0, minmax=(7.103650222612533, 10.896349777387467))
>>> var
Variance(statistic=10.0, minmax=(3.176724206..., 24.45910382...))
>>> std
Std_dev(statistic=2.9724954732045084, minmax=(1.7823367265645143, 4.945614605014631))
Now we generate some normally distributed random data, and get estimates of
mean and standard deviation with 95% confidence intervals for those
estimates:
>>> n_samples = 100000
>>> data = stats.norm.rvs(size=n_samples)
>>> res_mean, res_var, res_std = stats.bayes_mvs(data, alpha=0.95)
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> ax.hist(data, bins=100, density=True, label='Histogram of data')
>>> ax.vlines(res_mean.statistic, 0, 0.5, colors='r', label='Estimated mean')
>>> ax.axvspan(res_mean.minmax[0],res_mean.minmax[1], facecolor='r',
... alpha=0.2, label=r'Estimated mean (95% limits)')
>>> ax.vlines(res_std.statistic, 0, 0.5, colors='g', label='Estimated scale')
>>> ax.axvspan(res_std.minmax[0],res_std.minmax[1], facecolor='g', alpha=0.2,
... label=r'Estimated scale (95% limits)')
>>> ax.legend(fontsize=10)
>>> ax.set_xlim([-4, 4])
>>> ax.set_ylim([0, 0.5])
>>> plt.show()
r! r z20 < alpha < 1 is required, but alpha=%s was given.)r/ �
ValueErrorrM �mean�intervalrP rQ )�data�alpha�m�v�s�m_res�v_res�s_ress �8/usr/lib/python3/dist-packages/scipy/stats/_morestats.pyr0 r0 - s� � �n �d�m�m�G�A�q�!���z�z�U�a�Z�Z��M� �!� "� "� "�
������1�:�:�e�,�,�-�-�E��Q�V�V�X�X�q�z�z�%�0�0�1�1�E��A�F�F�H�H�a�j�j��/�/�0�0�E��%���� c � � t | � � }t |� � }|dk rt d� � �|� � � }|� � � }|dk r�t j |t j ||z � � �� � }t j t j |� � t j |d|z z � � �� � }t j |t j d|z � � |z �� � }n}|dz
}||z dz } |dz }
t j ||t j ||z � � �� � }t j
|
dt j | � � �� � }t j |
| �� � }|||fS ) a
'Frozen' distributions for mean, variance, and standard deviation of data.
Parameters
----------
data : array_like
Input array. Converted to 1-D using ravel.
Requires 2 or more data-points.
Returns
-------
mdist : "frozen" distribution object
Distribution object representing the mean of the data.
vdist : "frozen" distribution object
Distribution object representing the variance of the data.
sdist : "frozen" distribution object
Distribution object representing the standard deviation of the data.
See Also
--------
bayes_mvs
Notes
-----
The return values from ``bayes_mvs(data)`` is equivalent to
``tuple((x.mean(), x.interval(0.90)) for x in mvsdist(data))``.
In other words, calling ``<dist>.mean()`` and ``<dist>.interval(0.90)``
on the three distribution objects returned from this function will give
the same results that are returned from `bayes_mvs`.
References
----------
T.E. Oliphant, "A Bayesian perspective on estimating mean, variance, and
standard-deviation from data", https://scholarsarchive.byu.edu/facpub/278,
2006.
Examples
--------
>>> from scipy import stats
>>> data = [6, 9, 12, 7, 8, 8, 13]
>>> mean, var, std = stats.mvsdist(data)
We now have frozen distribution objects "mean", "var" and "std" that we can
examine:
>>> mean.mean()
9.0
>>> mean.interval(0.95)
(6.6120585482655692, 11.387941451734431)
>>> mean.std()
1.1952286093343936
r- zNeed at least 2 data-points.i� )�loc�scale� @r! ���)rc )r �lenrT rU �varr) �norm�mathr �t�gengamma�invgamma)rW �x�n�xbar�C�mdist�sdist�vdist�nm1�fac�vals r_ r/ r/ � sV � �n �d���A��A���A��1�u�u��7�8�8�8��6�6�8�8�D� �����A��4�x�x��"�t�4�9�Q��U�3C�3C�D�D�D���"�t�y��|�|�4�9�Q�"�q�&�\�;R�;R�S�S�S���"�q�� �#��'�0B�0B�Q�0F�G�G�G����!�e���!�e�b�j���B�h������T�Y�q�3�w�5G�5G�H�H�H���&�s�B�d�i��n�n�E�E�E���&�s�#�6�6�6���%���r` c � � | S �N� �rm s r_ �<lambda>r{ � � � �a� r` c � � | fS rx ry rz s r_ r{ r{ � � � �A�4� r` )�result_to_tuple� n_outputs�default_axisc � � |dk s|dk rt d� � �t |� � }t j |dz t j � � }t | � � } | j }|dk rt d� � �t j t j | � � � � rt j S t d|dz � � D ]}t j | |z d�� � ||<