+
    0i?                         R t . ROt^ RIt^ RIHtHt ^ RIHt ^ RIHt ^RI	H
t ^ RIHtHtHtHt RR ltRR ltRR ltRR	 ltRR
 ltRR ltRR ltRR ltRR ltRR ltR# )zB
Additional statistics functions with support for masked arrays.

N)float64ndarray)MaskedArray)_mstats_basic)normbetatbinomc                   R p\         P                  ! V R\        R7      p \        P                  ! \        P
                  ! V4      4      pVe   V P                  ^8X  d   V! WV4      pMAV P                  ^8  d   \        RV P                   24      h\         P                  ! WBWV4      p\         P                  ! VRR7      # )at  
Computes quantile estimates with the Harrell-Davis method.

The quantile estimates are calculated as a weighted linear combination
of order statistics.

Parameters
----------
data : array_like
    Data array.
prob : sequence, optional
    Sequence of probabilities at which to compute the quantiles.
axis : int or None, optional
    Axis along which to compute the quantiles. If None, use a flattened
    array.
var : bool, optional
    Whether to return the variance of the estimate.

Returns
-------
hdquantiles : MaskedArray
    A (p,) array of quantiles (if `var` is False), or a (2,p) array of
    quantiles and variances (if `var` is True), where ``p`` is the
    number of quantiles.

See Also
--------
hdquantiles_sd

Examples
--------
>>> import numpy as np
>>> from scipy.stats.mstats import hdquantiles
>>>
>>> # Sample data
>>> data = np.array([1.2, 2.5, 3.7, 4.0, 5.1, 6.3, 7.0, 8.2, 9.4])
>>>
>>> # Probabilities at which to compute quantiles
>>> probabilities = [0.25, 0.5, 0.75]
>>>
>>> # Compute Harrell-Davis quantile estimates
>>> quantile_estimates = hdquantiles(data, prob=probabilities)
>>>
>>> # Display the quantile estimates
>>> for i, quantile in enumerate(probabilities):
...     print(f"{int(quantile * 100)}th percentile: {quantile_estimates[i]}")
25th percentile: 3.1505820231763066 # may vary
50th percentile: 5.194344084883956
75th percentile: 7.430626414674935

c                   \         P                  ! \         P                  ! V P                  4       P	                  \
        4      4      4      pVP                  p\         P                  ! ^\        V4      3\        4      pV^8  d)   \         P                  Vn        V'       d   V# V^ ,          # \         P                  ! V^,           4      \        V4      ,          p\        P                  p\!        V4       F  w  rV! Wd^,           V	,          V^,           ^V	,
          ,          4      p
V
R,          V
RR ,
          p\         P"                  ! W4      pW^ V3&   \         P"                  ! WV,
          ^,          4      V^V3&   K  	  V^ ,          V^ V^ 8H  3&   VR,          V^ V^8H  3&   V'       d%   \         P                  ;V^V^ 8H  3&   V^V^8H  3&   V# V^ ,          # )zGComputes the HD quantiles for a 1D array. Returns nan for invalid data.   NNN)npsqueezesort
compressedviewr   sizeemptylenr   nanflatarangefloatr   cdf	enumeratedot)dataprobvarxsortednhdvbetacdfip_wwhd_means   &&&          X/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/stats/_mstats_extras.py_hd_1Dhdquantiles.<locals>._hd_1DP   su   **RWWT__%6%;%;G%DEFLLXXqTmW-q5ffBG	a5LIIacNU1X%((t_EQqS!GacAaC[1B2CR AffQ(GqsGffQ1 45BqsG % #1:1dai<"2;1dai<24&&8Bq$!)|r!TQY,/I!u    FcopydtypeBArray 'data' must be at most two dimensional, but got data.ndim = r0   )
maarrayr   r   
atleast_1dasarrayndim
ValueErrorapply_along_axisfix_invalid)r   r   axisr    r,   r'   results   &&&&   r+   hdquantilesr>      s    h< 88DuG4D
bjj&'A$))q.%99q=  448II;@ A A$$V4C@>>&u--r.   c                @    \        V R.WR7      pVP                  4       # )a  
Returns the Harrell-Davis estimate of the median along the given axis.

Parameters
----------
data : ndarray
    Data array.
axis : int, optional
    Axis along which to compute the quantiles. If None, use a flattened
    array.
var : bool, optional
    Whether to return the variance of the estimate.

Returns
-------
hdmedian : MaskedArray
    The median values.  If ``var=True``, the variance is returned inside
    the masked array.  E.g. for a 1-D array the shape change from (1,) to
    (2,).

      ?)r<   r    )r>   r   )r   r<   r    r=   s   &&& r+   hdmedianrA   |   s!    , se$8F>>r.   c                |   R p\         P                  ! V R\        R7      p \        P                  ! \        P
                  ! V4      4      pVf
   V! W4      pM@V P                  ^8  d   \        RV P                   24      h\         P                  ! W2W4      p\         P                  ! VRR7      P                  4       # )a  
The standard error of the Harrell-Davis quantile estimates by jackknife.

Parameters
----------
data : array_like
    Data array.
prob : sequence, optional
    Sequence of quantiles to compute.
axis : int, optional
    Axis along which to compute the quantiles. If None, use a flattened
    array.

Returns
-------
hdquantiles_sd : MaskedArray
    Standard error of the Harrell-Davis quantile estimates.

See Also
--------
hdquantiles

c                V   \         P                  ! V P                  4       4      p\        V4      p\         P                  ! \        V4      \
        4      pV^8  d   \         P                  Vn        \         P                  ! V4      \        V^,
          4      ,          p\        P                  p\        V4       F  w  rxV! WSV,          V^V,
          ,          4      p	V	R,          V	RR ,
          p
\         P                  ! V4      p\         P                  ! WRR ,          4      VR&   VRR;;; \         P                  ! V
RRR1,          VR^ R1,          ,          4      RRR1,          ,          uuu% \         P                  ! VP!                  4       V^,
          ,          4      WG&   K  	  V# )z%Computes the std error for 1D arrays.r   Nr   )r   r   r   r   r   r   r   r   r   r   r   r   r   
zeros_likecumsumsqrtr    )r   r   r!   r"   hdsdvvr%   r&   r'   r(   r)   mx_s   &&          r+   _hdsd_1D hdquantiles_sd.<locals>._hdsd_1D   s/   ''$//+,LxxD	7+q5DIYYq\E!A#J&((t_EQqS!QqS'*B2CR A --(CiiCRL 01CGH		!DbD'GEQrEN":;DbDAAHggcggi1q512DG % r.   Fr/   r2   r3   )r4   r5   r   r   r6   r7   r8   r9   r:   r;   ravel)r   r   r<   rJ   r'   r=   s   &&&   r+   hdquantiles_sdrM      s    02 88DuG4D
bjj&'A$"99q=  448II;@ A A$$XT=>>&u-3355r.   c                   \         P                  ! V RR7      p \        P                  ! WW$R7      pVP	                  V4      p\        P
                  ! WW$R7      pVP                  V4      ^,
          p\        P                  ! ^VR,          ,
          V4      p	\        P                  ! WiV,          ,
          WiV,          ,           34      # )a3  
Selected confidence interval of the trimmed mean along the given axis.

Parameters
----------
data : array_like
    Input data.
limits : {None, tuple}, optional
    None or a two item tuple.
    Tuple of the percentages to cut on each side of the array, with respect
    to the number of unmasked data, as floats between 0. and 1. If ``n``
    is the number of unmasked data before trimming, then
    (``n * limits[0]``)th smallest data and (``n * limits[1]``)th
    largest data are masked.  The total number of unmasked data after
    trimming is ``n * (1. - sum(limits))``.
    The value of one limit can be set to None to indicate an open interval.

    Defaults to (0.2, 0.2).
inclusive : (2,) tuple of boolean, optional
    If relative==False, tuple indicating whether values exactly equal to
    the absolute limits are allowed.
    If relative==True, tuple indicating whether the number of data being
    masked on each side should be rounded (True) or truncated (False).

    Defaults to (True, True).
alpha : float, optional
    Confidence level of the intervals.

    Defaults to 0.05.
axis : int, optional
    Axis along which to cut. If None, uses a flattened version of `data`.

    Defaults to None.

Returns
-------
trimmed_mean_ci : (2,) ndarray
    The lower and upper confidence intervals of the trimmed data.

Fr3   )limits	inclusiver<          @)
r4   r5   mstatstrimrmeantrimmed_stdecountr   ppfr   )
r   rO   rP   alphar<   trimmedtmeantstdedftppfs
   &&&&&     r+   trimmed_mean_cir^      s    T 88Du%Dll4)OGLLEYQE	t	q	 B5558BD88U%Z'Ez)9:;;r.   c                $   R p\         P                  ! V RR7      p V P                  ^8  d   \        RV P                   24      h\        P
                  ! \        P                  ! V4      4      pVf	   V! W4      # \         P                  ! W2W4      # )aT  
Returns the Maritz-Jarrett estimators of the standard error of selected
experimental quantiles of the data.

Parameters
----------
data : ndarray
    Data array.
prob : sequence, optional
    Sequence of quantiles to compute.
axis : int or None, optional
    Axis along which to compute the quantiles. If None, use a flattened
    array.

c                    \         P                  ! V P                  4       4      p V P                  p\         P                  ! V4      V,          R ,           P                  \        4      p\        P                  p\         P                  ! \        V4      \        4      p\         P                  ! ^V^,           \        R7      V,          pVRV,          ,
          p\        V4       F  w  rV! Wi^,
          W),
          4      V! Wy^,
          W),
          4      ,
          p
\         P                  ! W4      p\         P                  ! W^,          4      p\         P                  ! W^,          ,
          4      WX&   K  	  V# )r@   )r1   g      ?)r   r   r   r   r5   astypeintr   r   r   r   r   r   r   r   rF   )r   r'   r"   r   r%   mjxyr&   mWC1C2s   &&           r+   _mjci_1Dmjci.<locals>._mjci_1D  s    wwt()IIa#%--c2((XXc$i)IIa!7+a/1Ht_EQA#ac"WQs13%77AB'"BGGBQJ'BE	 %
 	r.   Fr3   r2   )r4   r5   r8   r9   r   r6   r7   r:   )r   r   r<   rj   r'   s   &&&  r+   mjcirl     s       88Du%Dyy1} 004		{< = 	= 	bjj&'A  ""84;;r.   c                    \        V^V,
          4      p\        P                  ! ^VR,          ,
          4      p\        P                  ! W^ ^ VR7      p\        WVR7      pWTV,          ,
          WTV,          ,           3# )a}  
Computes the alpha confidence interval for the selected quantiles of the
data, with Maritz-Jarrett estimators.

Parameters
----------
data : ndarray
    Data array.
prob : sequence, optional
    Sequence of quantiles to compute.
alpha : float, optional
    Confidence level of the intervals.
axis : int or None, optional
    Axis along which to compute the quantiles.
    If None, use a flattened array.

Returns
-------
ci_lower : ndarray
    The lower boundaries of the confidence interval.  Of the same length as
    `prob`.
ci_upper : ndarray
    The upper boundaries of the confidence interval.  Of the same length as
    `prob`.

rQ   )alphapbetapr<   r<   )minr   rW   rR   
mquantilesrl   )r   r   rX   r<   zxqsmjs   &&&&   r+   mquantiles_cimjrv   5  sc    6 q5y!EU2XA			4aqt	DB
t
%CSL"3w,''r.   c                    R p\         P                  ! V RR7      p Vf   V! W4      pV# V P                  ^8  d   \        RV P                   24      h\         P                  ! W2W4      pV# )a  
Computes the alpha-level confidence interval for the median of the data.

Uses the Hettmasperger-Sheather method.

Parameters
----------
data : array_like
    Input data. Masked values are discarded. The input should be 1D only,
    or `axis` should be set to None.
alpha : float, optional
    Confidence level of the intervals.
axis : int or None, optional
    Axis along which to compute the quantiles. If None, use a flattened
    array.

Returns
-------
median_cihs
    Alpha level confidence interval.

c                    \         P                  ! V P                  4       4      p \        V 4      p\	        V^V,
          4      p\        \        P                  ! VR,          VR4      4      p\        P                  ! W#,
          VR4      \        P                  ! V^,
          VR4      ,
          pV^V,
          8  dL   V^,          p\        P                  ! W#,
          VR4      \        P                  ! V^,
          VR4      ,
          p\        P                  ! W#,
          ^,
          VR4      \        P                  ! W2R4      ,
          pV^,
          V,           WE,
          ,          pW#,
          V,          \        W2^V,          ,
          V,          ,           4      ,          pWpV,          ,          ^V,
          W^,
          ,          ,          ,           WpW#,
          ^,
          ,          ,          ^V,
          WV,
          ,          ,          ,           3pV# )r   rQ   r@   )
r   r   r   r   rq   rb   r	   _ppfr   r   )	r   rX   r"   kgkgkkIlambdlimss	   &&       r+   _cihs_1Dmedian_cihs.<locals>._cihs_1Dn  s_   wwt()IE1U7#

58Q,-YYqs1S!EIIac!C$88%<FA13q%		!A#a(<<BiiAa$uyyS'99!Ve^bh'	E!1uai-001g5$s) 3313q5k!QuWdQ3i$779r.   Fr3   r2   )r4   r5   r8   r9   r:   )r   rX   r<   r   r=   s   &&&  r+   median_cihsr   W  sv    . 88Du%D$& M 99q=  448II;@ A A$$XTAMr.   c                   \         P                  ! WR7      \         P                  ! WR7      rC\        P                  ! WR7      \        P                  ! WR7      re\        P
                  ! W4,
          4      \         P                  ! V^,          V^,          ,           4      ,          p^\        P                  ! V4      ,
          # )a  
Compares the medians from two independent groups along the given axis.

The comparison is performed using the McKean-Schrader estimate of the
standard error of the medians.

Parameters
----------
group_1 : array_like
    First dataset.  Has to be of size >=7.
group_2 : array_like
    Second dataset.  Has to be of size >=7.
axis : int, optional
    Axis along which the medians are estimated. If None, the arrays are
    flattened.  If `axis` is not None, then `group_1` and `group_2`
    should have the same shape.

Returns
-------
compare_medians_ms : {float, ndarray}
    If `axis` is None, then returns a float, otherwise returns a 1-D
    ndarray of floats with a length equal to the length of `group_1`
    along `axis`.

Examples
--------

>>> from scipy import stats
>>> a = [1, 2, 3, 4, 5, 6, 7]
>>> b = [8, 9, 10, 11, 12, 13, 14]
>>> stats.mstats.compare_medians_ms(a, b, axis=None)
1.0693225866553746e-05

The function is vectorized to compute along a given axis.

>>> import numpy as np
>>> rng = np.random.default_rng()
>>> x = rng.random(size=(3, 7))
>>> y = rng.random(size=(3, 8))
>>> stats.mstats.compare_medians_ms(x, y, axis=1)
array([0.36908985, 0.36092538, 0.2765313 ])

References
----------
.. [1] McKean, Joseph W., and Ronald M. Schrader. "A comparison of methods
   for studentizing the sample median." Communications in
   Statistics-Simulation and Computation 13.6 (1984): 751-773.

rp   )	r4   medianrR   stde_medianr   absrF   r   r   )group_1group_2r<   med_1med_2std_1std_2rg   s   &&&     r+   compare_medians_msr     s|    d ii2BIIg4PE((<((< 
u}q5!8(; <<Atxx{?r.   c                    R p\         P                  ! WR7      P                  \        4      p Vf	   V! V 4      # \         P                  ! W!V 4      # )a  
Returns an estimate of the lower and upper quartiles.

Uses the ideal fourths algorithm.

Parameters
----------
data : array_like
    Input array.
axis : int, optional
    Axis along which the quartiles are estimated. If None, the arrays are
    flattened.

Returns
-------
idealfourths : {list of floats, masked array}
    Returns the two internal values that divide `data` into four parts
    using the ideal fourths algorithm either along the flattened array
    (if `axis` is None) or along `axis` of `data`.

c                    V P                  4       p\        V4      pV^8  d!   \        P                  \        P                  .# \	        VR,          R,           ^4      w  r4\        V4      p^V,
          W^,
          ,          ,          WAV,          ,          ,           pW#,
          p^V,
          W,          ,          WAV^,
          ,          ,          ,           pWW.# )   g      @g?)r   r   r   r   divmodrb   )r   rd   r"   jhqlorz   qups   &       r+   _idfidealfourths.<locals>._idf  s    OOFq5FF266?"qte|A&FsAcFlQtV#EsADj1qsV8#zr.   rp   )r4   r   r   r   r:   )r   r<   r   s   && r+   idealfourthsr     sD    ,
 774#((5DDz""4t44r.   c                <   \         P                  ! V RR7      p Vf   T pM*\        P                  ! \        P                  ! V4      4      pV P
                  ^8w  d   \        R4      hV P                  4       p\        V RR7      pRVR,          V^ ,          ,
          ,          VR	,          ,          pV R
,          VR,          V,           8*  P                  ^ 4      pV R
,          VR,          V,
          8  P                  ^ 4      pWV,
          RV,          V,          ,          # )a  
Evaluates Rosenblatt's shifted histogram estimators for each data point.

Rosenblatt's estimator is a centered finite-difference approximation to the
derivative of the empirical cumulative distribution function.

Parameters
----------
data : sequence
    Input data, should be 1-D. Masked values are ignored.
points : sequence or None, optional
    Sequence of points where to evaluate Rosenblatt shifted histogram.
    If None, use the data.

Fr3   Nz#The input array should be 1D only !rp   g333333?rQ   r   皙?)NNNN)Nr   )
r4   r5   r   r6   r7   r8   AttributeErrorrV   r   sum)r   pointsr"   rr   nhinlos   &&     r+   rshr     s      88Du%D~rzz&12yyA~BCC

AT%AquQqTzQY&A<6&>A--
2
21
5C<&.1,,
1
1!
4CG1Qr.   )
r   r>   rA   rM   r   r   rl   rv   r   r^   )g      ?r@   g      ?NF)r   F)r   N))r   r   )TT皙?N)r   r   N)r   N)N)__doc____all__numpyr   r   r   numpy.mar4   r    r   rR   scipy.stats.distributionsr   r   r   r	   r>   rA   rM   r^   rl   rv   r   r   r   r    r.   r+   <module>r      sc     "    % : :].@4<6~0<f*<Z(D0f6r%5P r.   