+
    ,i@                    
   ^ RI t ^ RIt^ RIHtHtHt ^ RIHt ^ RI	H
t
 ^ RIHtHt ^ RIHtHt ^ RIHt ^ RIHtHtHtHt ^ RIHu Ht R	 t] P6                  P9                  R
. RDO4      ] P6                  P9                  R. REO4      R 4       4       t] P6                  P9                  R
. RDO4      R 4       t] P6                  P9                  R
. RDO4      ] P6                  P9                  R. REO4      ] P6                  P9                  RRR.4      R 4       4       4       t] P6                  P@                  ] P6                  PC                  R4      ] P6                  P9                  R
. RDO4      R 4       4       4       t"RRFRRGRRH/t#] P6                  P9                  R]#PI                  4       4      R 4       t%R t&R t'RRRRRR/t(] P6                  P@                  ] P6                  P9                  R](PI                  4       4      R 4       4       t)RRRR/t*] P6                  P@                  ] P6                  P9                  R]*PI                  4       4      R  4       4       t+] P6                  P9                  R
RR.4      ] P6                  P9                  R^ ^.4      R! 4       4       t,] P6                  PC                  R"4      ] P6                  P9                  R
. RDO4      ] P6                  P9                  R^ ^.4      R# 4       4       4       t-] P6                  P9                  R
. RDO4      R$ 4       t.] P6                  P9                  R
. RDO4      R% 4       t/R& t0] P6                  P9                  R'^ R(.4      R) 4       t1] P6                  PC                  R*4      ] P6                  P9                  R
. RDO4      R+ 4       4       t2R, t3] P6                  P9                  R-R.R/.4      R0 4       t4] P6                  P9                  R1. RIO4      ] P6                  P9                  R. REO4      R2 4       4       t5R3 t6] P6                  P9                  R. REO4      R4 4       t7] P6                  P@                  ] P6                  P9                  R
. RDO4      R5 4       4       t8] P6                  P@                  ] P6                  Ps                  R64      R7 4       4       t:R8 t; ! R9 R:4      t< ! R; R<4      t= ! R= R>4      t>R? t?] P6                  P9                  R@. RJO4      RA 4       t@ ! RB RC4      tAR# )K    N)assert_allcloseassert_equalsuppress_warnings)rng_integers)is_numpy)xp_assert_closexp_assert_equal)statsspecial)root)	bootstrapmonte_carlo_testpermutation_testpowerc                  ~   R p \         P                  ! \        V R7      ;_uu_ 4        \        ^\        P
                  4       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        \        4       \        P
                  4       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO^.3\        P
                  4       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO. RO3\        P
                  RR7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        ^\        P
                  R	R
7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  RR7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  RR7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  R R7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  RR7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  R R7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  RR7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  R	R7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  ^
R7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  ^ R7       RRR4       Rp \         P                  ! \        V R7      ;_uu_ 4        \        . RO3\        P
                  RR7       RRR4       R#   + '       g   i     ELZ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELo; i  + '       g   i     EL5; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELM; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELe; i  + '       g   i     R# ; i)!z%`data` must be a sequence of samples.matchNz(`data` must contain at least one sample.z>each sample in `data` must contain two or more observations...z=When `paired is True`, all samples must have the same length T)paired0`vectorized` must be `True`, `False`, or `None`.ekki
vectorized`axis` must be an integer.      ?axisz!could not convert string to floatni)confidence_levelz-`n_resamples` must be a non-negative integer.n_resamples     D@+`batch` must be a positive integer or None.batchz`method` must be inmethodz?`bootstrap_result` must have attribute `bootstrap_distribution')bootstrap_resultz5Either `bootstrap_result.bootstrap_distribution.size`,SeedSequence expects int or sequence of intsherringrng         r-   r.   r/      )pytestraises
ValueErrorr   npmeantuple	TypeError)messages    C/usr/lib/python3/dist-packages/scipy/stats/tests/test_resampling.pytest_bootstrap_ivr<      s|   5G	z	1	1!RWW 
2 9G	z	1	1%'277# 
2 OG	z	1	19qc"BGG, 
2 OG	z	1	19l+RWWTB 
2 AG	z	1	1!RWW0 
2 +G	z	1	19,c2 
2 2G	z	1	19,$? 
2 >G	z	1	19,U; 
2 >G	z	1	19,V< 
2 <G	z	1	19,u5 
2 <G	z	1	19,v6 
2 $G	z	1	19,7 
2 PG	z	1	19,"= 
2 FG	z	1	19,Q7 
2 =G	y	0	09,Y7 
1	0q 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
2	1	1 
1	0	0s   R0#R' R;#S S#+ S79 T T T3# U1 U? U/ V V) V+R$	'R8	;S	S 	#S4	7T	T	T0	3U	U	U,	/V 	V	V(	+V<	r&   basic
percentileBCar   c           
      <   \         P                  P                  ^ 4      pVP                  ^
^^4      p\	        V3\         P
                  RV ^ V^dR7      p\         P                  P                  ^ 4      p\	        V3\         P
                  ^
V V^dVR7      p\        VP                  P                  VP                  P                  4       \        VP                  P                  VP                  P                  4       \        VP                  VP                  4       R# )r   N)r$   r&   random_stater   r    )r$   r&   r   r    rA   )r6   randomRandomStaterandr   r7   r   confidence_intervallowhighstandard_error)r&   r   r+   xres1res2s   &&    r;   test_bootstrap_batchrL   O   s     ))


"CRAaT277$v"#$CAD
))


"CaT277"VCcCD ))--t/G/G/K/KL))..0H0H0M0MN$$d&9&9:    c                   aaa	 \         P                  P                  ^ 4      p^dpVP                  V4      oVP                  V4      o	RR loRVVV	3R llp\         P                  ! \        S4      4      p\        V3V^ R7      p\        SS	3SR^ R7      p\        VP                  VP                  4       \        VP                  VP                  4       R# )r   c                 @    W,
          ^,          P                  VR7      # )r.   r   r7   rI   yr   s   &&&r;   my_statistic+test_bootstrap_paired.<locals>.my_statisticj   s    qD))rM   c                 <   < SV ,          pSV ,          pS! W#4      pV# N )ir   abresrS   rI   rR   s   &&   r;   my_paired_statistic2test_bootstrap_paired.<locals>.my_paired_statisticm   s$    aDaD1 
rM   r*   T)r   r+   N)
r6   rB   rC   rD   arangelenr   r   rE   rH   )
r&   r+   nr\   rX   rJ   rK   rS   rI   rR   s
   &      @@@r;   test_bootstrap_pairedrc   b   s     ))


"CAAA*  			#a&AaT.A6DaV\$A>DD,,d.F.FGD'')<)<=rM   r   TFc           
         \         P                  P                  ^ 4      pRR lpRpWQ,          pVP                  V4      pVP                  V4      pVP                  V4      p	\	        WxV	3WBV ^ ^ ^dR7      p
V
P
                  P                  V
P                  P                  R,           8X  g   Q h. ROpWkV&   \         P                  ! VP                  V4      V4      p\         P                  ! VP                  V4      V4      p\         P                  ! V	P                  V4      V4      p	\	        WxV	3WBV ^ V^dR7      p\        VP                  P                  V
P                  P                  4       \        VP                  P                  V
P                  P                  4       \        VP                  V
P                  4       \        V4      pVP                  V4       \!        VP                  P                  P                  V4       \!        VP                  P                  P                  V4       \!        VP                  P                  V4       R# )r   c                     V P                  VR 7      VP                  VR 7      ,           VP                  VR 7      ,           # r   rP   )rI   rR   zr   s   &&&&r;   rS   /test_bootstrap_vectorized.<locals>.my_statistic   s3    vv4v 166t6#44qvv4v7HHHrM   )r   r&   r+   r   r    Nr^   )
         )d   )r-   r-   r-   )r6   rB   rC   rD   r   bootstrap_distributionshaperH   broadcast_toreshaper   rE   rF   rG   listpopr   )r&   r   r   r+   rS   rn   	n_samplesrI   rR   rg   rJ   rp   rK   result_shapes   &&&           r;   test_bootstrap_vectorizedru   |   s    ))


"CI EIAAAaAYF5D''--""((612 3 2 GDM
		'*E2A
		'*E2A
		'*E2AaAYF38D D,,00,,002D,,11,,113D'')<)<=;LT))--33\B))..44lC$$**L9rM   z#MemoryError with BCa observed in CIc                    \         P                  P                  R 4      p\        P                  P                  ^^RVR7      pRp\        P                  ! \        V4      ^,
          \         P                  ! V4      \        P                  ! V4      R7      pVP                  VR7      pVP                  4       p\        V3\         P                  RWR7      p\        R/ VBRV/B p\        VP                  VRR	7       \        VP                   VR
R7       VP#                  \        ^ VR7      4       \        R/ VBRVRR/B p\        VP                  P$                  VP'                  V4      RR	7       VP#                  \        ^ VR7      4       \        R/ VBRVRR/B p\        VP                  P(                  VP'                  ^V,
          4      RR	7       R# )l   )ICbX    )locscalesizerA   ffffff?)dfrx   ry   )
confidence)data	statisticr    r&   r+   r   gMb@?rtolga2U0*3?atolr    r'   alternativelessgreaterNrW   )r6   rB   default_rngr
   normrvstra   r7   semintervalstddictr   r   rE   rH   updaterG   ppfrF   )	r&   r+   r~   alphadistexpected_intervalexpected_seconfigr[   s	   &        r;   test_bootstrap_against_theoryr      sg   
 ))

 3
4C::>>aqt#>FDE77c$ikrwwt}EIIdOLD7((*Kw"''t*F

5f
5u
5CC++->TJC&&$?
MM$1s;<

If
Iu
I&
ICC++00$((5/M
MM$1s;<

Lf
Lu
L)
LCC++//!E'1BNrM   zmethod, expectedc                     \         P                  ! . RO4      p\        V3\         P                  RV ^ R7      p\	        VP
                  VRR7       R# )ri   i@B )r    r&   r+   g{Gzt?r   N)ri   rk         )@r   g+@            "   2   Q   Y   y         )r6   arrayr   r7   r   rE   )r&   expectedrI   r[   s   &&  r;   test_bootstrap_against_Rr      sD    " 	 5 	6A
QD"''wvCC++XEBrM   c                     . R
Op . ROpR p\         P                  P                  R4      p\        P                  ! W3VR^dVR7      p\        P                  ! W3VR^dVR7      p\        P                  ! W3VR^dVR7      p\         P
                  ! VP                  4      p\         P
                  ! VP                  4      p\         P
                  ! VP                  4      p	Rp
Wz,
          \        V
4      ,          pW,
          \        V
4      ,          pW,
          \        V
4      ,          pVR8  g   Q hVR8  g   Q h\        V4      R8  g   Q hR	# )璑bF?c                 n    \         P                  ! WR 7      p\         P                  ! WR 7      pW4,
          # rf   )r
   skew)rI   rR   r   s1s2s   &&&  r;   r   1test_multisample_BCa_against_R.<locals>.statistic   s%    ZZ%ZZ%wrM   l   tgy4r=   )r&   r$   r+   r>   bcag333333?Q?N)r   gp?g|Hܿgxy[e}u׿g*g_?ggi6g2?)gF?gK?g&F}/?g?g(iC?g}$ץ?g hu?gfj}!?g1*g333333ÿ)r6   rB   r   r
   r   r7   rE   abs)rI   rR   r   r+   	res_basicres_percentres_bca	mid_basicmid_percentmid_bca	mid_wboot
diff_basicdiff_percentdiff_bcas                 r;   test_multisample_BCa_against_Rr      s'   	.A	9A
 ))

 2
3C	'&)s4I//1&)L(+6Kooqfi$'S2G 	556I''+99:Kggg112G I 'Y7J+S^;L#S^3H $x=4rM   c                     \         P                  ! . RO4      p \         P                  ! . RO4      pRR lpW.p\        P                  ! W24      pRpRpVP                  p^dp\
        P                  ! W2WVWx4      w   r\        V
R4       R# )	ri   c                 h    \         P                  ! WR 7      \         P                  ! WR 7      ,
          # rf   r6   r7   )rg   rR   r   s   &&&r;   r   :test_BCa_acceleration_against_reference.<locals>.statistic&  s    wwq$rwwq'<<<rM   r{   ge{?N)	ri         (   .   r   4   h      )   r   &   ^   c         r   r_   )r6   r   r
   r   rm   _resampling_bca_intervalr   )rR   rg   r   r~   r[   r   r   theta_hat_br$   _a_hats              r;   'test_BCa_acceleration_against_referencer     s     	78A
/0A= 6D
//$
*CDE,,KE++DT,7@KAqE/0rM   i  i  c                    \         P                  P                  R 4      p^dpRpRp\        P                  ! ^^R7      pVP                  4       pRpVP                  W3VR7      p	\        V	3\         P
                  VV^2V R	VR7      p
V
P                  p\         P                  ! V^ ,          V8  W{^,          8  ,          4      pW8X  g   Q h\        P                  ! WV4      P                  pVR8  g   Q hR# )
i8   ?rx   ry   i  rz   rA   )r   r   r    r$   r&   r   r+   皙?Nr_   )r6   rB   r   r
   r   r7   r   r   rE   sum	binomtestpvalue)r&   r   r+   rb   r    r   r   	stat_truen_replicationsr~   r[   cici_contains_truer   s   &&            r;   #test_bootstrap_against_itself_1sampr   :  s     ))


(CAK ::!1%D		I N88.,38?D
TG gg%5 +!C 
	 	 B vvr!uy0YA5FGH''' __--//5v C<<rM   i|  iz  c                 d   \         P                  P                  ^ 4      p^dp^xpRpRpRR lp\        P                  ! ^ ^R7      p\        P                  ! R^R7      p	VP                  4       V	P                  4       ,
          p
RpVP                  W3VR7      pV	P                  W3VR7      p\        W3VVV^2V R
VR7      pVP                  p\         P                  ! V^ ,          V
8  W^,          8  ,          4      pVV8X  g   Q h\        P                  ! VVV4      P                  pVR8  g   Q hR	# )r   r   r   c                 n    \         P                  ! WR 7      p\         P                  ! WR 7      pW4,
          # rf   r   )data1data2r   mean1mean2s   &&&  r;   my_stat4test_bootstrap_against_itself_2samp.<locals>.my_statw  s&    ))}rM   r   r     r   )r   r   r    r$   r&   r   rA   Nr_   r^   )r6   rB   rC   r
   r   r7   r   r   rE   r   r   r   )r&   r   r+   n1n2r    r   r   dist1dist2r   r   r   r   r[   r   r   r   s   &&                r;   #test_bootstrap_against_itself_2sampr   g  s+    ))


"C	B	BK JJ1A&EJJ3a(E

uzz|+I NIIN/cIBEIIN/cIBE
UN%%5 +!!$&C 
	 	 B vvr!uy0YA5FGHx''' __-~-//5v C<<rM   c           
        a	 R ^ /R lo	V	3R lp\         P                  P                  ^ 4      pVP                  ^^4      pVP                  ^^4      pVP                  ^^4      p\	        WEV3S	RV^dV ^ R7      p\	        WEV3VRV^dV ^ R7      p\        VP                  VP                  4       \        VP                  VP                  4       R# )r   c                 .   a  \        V 3R  lV 4       4      # )c              3   D   <"   T F  qP                  S4      x  K  	  R # 5irV   rP   .0sampler   s   & r;   	<genexpr>Etest_bootstrap_vectorized_3samp.<locals>.statistic.<locals>.<genexpr>       84;;t$$4    r   r   r~   s   d*r;   r   2test_bootstrap_vectorized_3samp.<locals>.statistic      84888rM   c                  L   < V  F  pVP                   ^8X  d   K  Q h	  S! V R^ / # r-   r   ndimr~   r   r   s   * r;   statistic_1d5test_bootstrap_vectorized_3samp.<locals>.statistic_1d  /    F;;!### $'Q''rM   T)r   r   r    r&   r+   FNr6   rB   rC   rD   r   r   rE   rH   )
r&   r   r  r+   rI   rR   rg   rJ   rK   r   s
   &&       @r;   test_bootstrap_vectorized_3sampr    s    9a 9( ))


"CAAAAAAaAY	dCAGDaAYCAGDD,,d.F.FGD'')<)<=rM   z'Failure is not concerning; see gh-14107c                 P  a RR loV3R lp\         P                  P                  ^ 4      pVP                  ^^4      p\	        V3SRV^dRV ^ R7      p\	        V3VRV^d^
V ^ R7      p\        VP                  VP                  4       \        VP                  VP                  4       R# )r   c                 &    V P                  VR 7      # rf   rP   rI   r   s   &&r;   r   2test_bootstrap_vectorized_1samp.<locals>.statistic  s    vv4v  rM   c                 >   < V P                   ^8X  g   Q hS! V ^ R7      # r-   r   r  )rI   r   s   &r;   r  5test_bootstrap_vectorized_1samp.<locals>.statistic_1d  s     vv{{##rM   TN)r   r   r    r$   r&   r+   Fr   r  )r&   r   r  r+   rI   rJ   rK   r   s   &&     @r;   test_bootstrap_vectorized_1sampr    s    !$
 ))


"CAAaT9D!$DD aT<E!$BvD D,,d.F.FGD'')<)<=rM   c           
      l   ^#R.,          pV R8X  d   \         P                  ! RR7      ;_uu_ 4        Rp\        P                  ! \        P
                  VR7      ;_uu_ 4        \        V.\         P                  V R7      p\        VP                  \         P                  \         P                  34       RRR4       RRR4       M3\        V.\         P                  V R7      p\        VP                  R	4       \        XP                  ^ 4       R#   + '       g   i     Ld; i  + '       g   i     L;; i)
#        @r?   ignore)invalidz0The BCa confidence interval cannot be calculatedr   r%   N)r  r  )r6   errstater3   warnsr
   DegenerateDataWarningr   r7   r   rE   nanrH   )r&   r~   msgr[   s   &   r;   test_bootstrap_degenerater    s    =D[[**DCe99EE"''&AS44rvvrvv6FG F +* "''&9S,,.>?##Q' FE +*s$   1D#"AD	4D#D D##D3	c           	      f   \         P                  P                  R 4      p\        P                  ! ^^R7      pVP                  ^dVR7      pV3p\        V\        P                  V ^d\         P                  P                  R4      R7      p\        V\        P                  V ^d\         P                  P                  R4      RR7      p\        VP                  VP                  4       \        VP                  VP                  4       \        VP                  \         P                  4      '       g   Q hR# )l   E<1

 r   r   i[%  r&   r    r+   F)r&   r    r+   r   N)r6   rB   r   r
   r   r   r   r   r   rE   rH   
isinstancefloat64)r&   r+   r   r~   r[   refs   &     r;   test_bootstrap_gh15678r!    s     ))


0C::!1%D8838/D7D
D%**V		--d35C D%**V		--d3GCC++S-D-DEC&&(:(:;c(("**5555rM   c            	         \         P                  P                  R 4      p \        P                  ! ^^R7      pVP                  ^dV R7      p\         P                  ! V4      pV3p\        V\         P                  R^d\         P                  P                  R4      R7      pW4P                  P                  8X  g   Q h\        \         P                  ! V4      ) \         P                  R^d\         P                  P                  R4      R7      p\        VP                  P                  ) VP                  P                  4       \        VP                  P                  ) VP                  P                  4       R# )l   n!|'x`5 r   r   r?   if  r  N)r6   rB   r   r
   r   r   minr   rE   rF   r   maxr   rG   )r+   r   r~   true_minr[   rK   s         r;   test_bootstrap_minr&    s    ))

 0
1C::!1%D8838/Dvvd|H7D
D"&&C		--d35C..22222bhhtn_bffU..t46DS,,000,,113S,,111,,002rM   additional_resamplesr   c           
         \         P                  P                  R 4      pVP                  ^dR7      pRpT pW0,           p\         P                  P                  R4      p\        P                  ! V3\         P
                  W1RRR7      p\        P                  ! V3\         P
                  WARRVR	7      p\         P                  P                  R4      p\        P                  ! V3\         P
                  WQRRR7      p\        VP                  VP                  R
R7       \        VP                  VP                  R
R7       R# )l    ]4M rz   r   l   mdpi4 r{   r>   )r    r+   r   r&   r   r?   )r    r+   r   r&   r'   +=r   N)	r6   rB   r   r
   r   r7   r   rH   rE   )r'  r+   rI   r   r   n3r[   r   s   &       r;   test_re_bootstrapr,    s     ))

 0
1C


A	B	B		"B
))

 2
3C
//1$R+/FC
//1$R+/+.0C ))

 2
3C
//1$R+/?C C&&(:(:GC++S-D-D rM   zSensible to machine precisionc                    \         P                  P                  R 4      p\        P                  ! ^^R7      pVP                  ^dVR7      3p\        V\         P                  VRR7      p\        P                  ! R/ VBRR/B pVP                  \        ^ VR7      4       \        P                  ! R/ VBRRRR	/B p\        P                  ! R/ VBRRRR
/B p\        VP                  P                  VP                  P                  RR7       \        VP                  P                  VP                  P                  RR7       \         P                  ! VP                  P                  4      '       g   Q h\         P                  ! VP                  P                  4      '       g   Q h\         P"                  ! \$        RR7      ;_uu_ 4        \        P                  ! R/ VBRR/B  RRR4       R#   + '       g   i     R# ; i)l   @Qixt r   r   )r~   r   r+   r   r   r   r   r{   r   r   r   r*  r   z`alternative` must be one ofr   z	ekki-ekkiNr_   rW   )r6   rB   r   r
   r   r   r   r   r   r   r   rE   rG   rF   isneginfisposinfr3   r4   r5   )r&   r+   r   r~   r   r   lgs   &       r;   test_bootstrap_alternativer2    sw    ))

 3
4C::!1%DHH3cH24Dtrvv3R@F7&737A
MM$1q9:L&L4LVLAO&O4OYOAA))..0E0E0J0J A))--q/D/D/H/H ;;q,,001111;;q,,112222	z)G	H	H:&:k: 
I	H	H	Hs   G00H	c            	      "   Rp \         P                  P                  ^ 4       \         P                  P                  ! V !  p\	        \
        P                  ! V4      4      p\        V R,          4       FE  pVRVR3,          p\         P                  ! WRR7      p\         P                  ! WE4      '       d   KE  Q h	  \         P                  ! \        \
        P                  ! V^R7      4      RR7      p\         P                  ! Wb4      '       g   Q hR# )	r/   .NNNr   r#   Nr/   r1         r_   )r6   rB   seedrD   nextr   _jackknife_resamplerangedeletearray_equalconcatenaterq   )rn   rI   rR   rX   slcr   y2s          r;   test_jackknife_resamplerB  2  s    EIINN1
		A[,,Q/0A59 Q	l99Q+~~c,,,,  
[<<QaHI
!B>>"    rM   rng_namerC   r   c                    \        \        P                  V R 4      pVf   \        P                  ! V  R24       V! ^ 4      pV! ^ 4      p^
pRp\        P                  P                  ^ 4       \        P                  P                  ! V!  p\        P                  ! WdVR7      p\        V4       FT  pVRVR3,          p	\        V^ VR,          VR,          4      p
VRV
3,          p\        P                  ! W4      '       d   KT  Q h	  R # )Nz not available.r*   .r4  r5  r_   )getattrr6   rB   r3   skipr9  rD   r   _bootstrap_resampler<  r   r>  )rC  r+   rng1rng2r    rn   rI   rR   rX   r@  jsr   s   &           r;   test_bootstrap_resamplerK  E  s    
"))Xt
,C
{xj01q6Dq6DKEIINN1
		A''DAA; Q	l$59eBi8S"W:~~c,,,,  rM   scorec                     Rp\         P                  P                  ^ 4       \         P                  P                  ! V!  p\        P
                  ! W0RR7      pR pV! W0RR7      ^d,          p\        WFR4       R# )ri   r   c                 N    \         P                  ! \        P                  W V4      # rV   )r6   apply_along_axisr
   percentileofscore)rY   rL  r   s   &&&r;   vectorized_pos0test_percentile_of_score.<locals>.vectorized_posg  s    ""5#:#:DUKKrM   V瞯<N)ri         r_   )r6   rB   r9  rD   r   _percentile_of_scorer   )rL  r   rn   rI   prQ  p2s   &&     r;   test_percentile_of_scorerY  _  s`     EIINN1
		A((;AL 
r	*3	.BA5!rM   c                  l   Rp \         P                  P                  ^ 4      pVP                  ! V !  pVP                  ! V RR !  ^d,          p\        P
                  ! W#4      p\        V ^ ,          4       F<  pWE,          p\         P                  ! W%,          W5,          RR7      p\        WgR4       K>  	  R# )ri   Nr   rS  )ri   rT  r_   )	r6   rB   rC   rD   r   _percentile_along_axisr<  r>   r   )rn   r+   rI   qrR   rX   r[   r   s           r;   test_percentile_along_axisr]  o  s    
 E
))


"C%A%*#A**10A58_d==qt"5u- rM   c                 4  a	 R  o	V	3R lp\         P                  ! V4      p\        P                  P	                  ^ 4      pVP                  ^^^4      pVP                  ^^^4      pVP                  ^^^4      pS	! WEW`R7      pV! WEW`R7      p\        Wx4       R# )c                 .   a  \        V 3R  lV 4       4      # )c              3   D   <"   T F  qP                  S4      x  K  	  R # 5irV   rP   r   s   & r;   r   >test_vectorize_statistic.<locals>.statistic.<locals>.<genexpr>  r   r   r   r   s   d*r;   r   +test_vectorize_statistic.<locals>.statistic  r   rM   c                  L   < V  F  pVP                   ^8X  d   K  Q h	  S! V R^ / # r   r  r  s   * r;   r  .test_vectorize_statistic.<locals>.statistic_1d  r  rM   r   N)r   _vectorize_statisticr6   rB   rC   rD   r   )
r   r  
statistic2r+   rI   rR   rg   rJ   rK   r   s
   &        @r;   test_vectorize_statisticrg    s    9( 11,?J
))


"CAqAAqAAqAQ1(DaA)DDrM   c           
         \         P                  P                  R 4      pRp\        P                  P
                  ! VRR	RV/ pR p\        V3W@R
R^VR7      p\         P                  ! VP                  P                  P                  V8  VP                  P                  P                  V8  ,          ^ R7      p\         P                  ! V^Z8  4      '       g   Q h\         P                  ! V^d8*  4      '       g   Q hVP                  P                  P                  R8X  g   Q hVP                  P                  P                  R8X  g   Q hVP                  P                  R8X  g   Q hVP                  P                  R8X  g   Q hR# )l   s: rz   rA   c           	          \         P                  ! \         P                  ! W4      \         P                  ! W^R7      .4      # )r-   )ddof)r6   asarrayr7   r   )r~   r   s   &&r;   r   /test_vector_valued_statistic.<locals>.statistic  s1    zz2774.66$157 8 	8rM   '  )r&   r   r    r$   rA   r   N)r-         ?)rl   rl   r_   r.   rl   )r.   rl   rm  )r6   rB   r   r
   r   r   r   r   rE   rF   TrG   allrn   rH   rm   )r&   r+   paramsr   r   r[   countss   &      r;   test_vector_valued_statisticrt    sN    ))



+CFZZ^^VG*G3GF8 VIyb $CcCC VVS,,0022V;..3355>@F 66&B,66&C-    ""&&,,888""''--999##x///%%++~===rM   zignore::RuntimeWarningc                    aa \         P                  P                  R 4      p R oV3R loV3R lp. R	O. R
O. RO. RO. RO.p\         P                  ! V4      P                  p\        W!V RR7      p\        VSV RR7      p\        VP                  P                  ^ ,          VP                  P                  RR7       \        VP                  P                  ^ ,          VP                  P                  RR7       R# )l   \Qc                 <   V P                  V4      pVP                  V4      pWR,          ,
          WR,          ,
          ,          P                  V4      p^V,          V P                  V4      VP                  V4      ,           W4,
          ^,          ,           ,          # ).).N)r7   var)rI   rR   r   xmymcovs   &&&   r;   concordance9test_vector_valued_statistic_gh17715.<locals>.concordance  sn    VVD\VVD\yM!aY-&78>>tDCAEE$K!%%+5QFGGrM   c                 ^   < W,           pW,           p\         P                  ! S! WVV4      4      # rV   )r6   
nan_to_num)tptnfpfnr   actualr   r{  s   &&&&&  r;   r   7test_vector_valued_statistic_gh17715.<locals>.statistic  s'    7}}[4@AArM   c                 H   < S! . VOV N5!  \         P                  R 3,          # ).)r6   newaxis)r   argsr   s   $*r;   statistic_extradim@test_vector_valued_statistic_gh17715.<locals>.statistic_extradim  s#    %$%%bjj#o66rM   T)r+   r   rS  r   N)r1   r   r   r.   )r.   r-   r.   r-   )r   r7  r   r   )r   r7  r/   r   )r      r-   r   )
r6   rB   r   r   rp  r   r   rE   rF   rG   )r+   r  r~   r[   r   r{  r   s        @@r;   $test_vector_valued_statistic_gh17715r    s     ))

 2
3CHB
7 	D
 88D>D
D#d
CC
D)T
:CC++//2++//e=C++003++00u>rM   c                     \         P                  P                  R 4      p V P                  R4      pV P                  R4      pR p\        P                  ! W3V4       \        P                  ! VP
                  VP
                  3V^R7       Rp\        P                  ! \        VR7      ;_uu_ 4        \        P                  ! WR,          3V4       RRR4       \        P                  ! WR	,          3V4       \        P                  ! VP
                  VP
                  R
,          3V^R7       R#   + '       g   i     Lg; i)iF|c                 F    \         P                  ! WVR 7      P                  # rf   r
   	ttest_indr   rQ   s   &&&r;   r    test_gh_20850.<locals>.statistic  s    q$/999rM   r   /Array shapes are incompatible for broadcasting.r   N)ri   r.   )rj   r.   )Nri   Nr   )r  r   r-   N)r  r  )	r6   rB   r   r
   r   rp  r3   r4   r5   )r+   rI   rR   r   r:   s        r;   test_gh_20850r    s    
))



+C

7A

7A: 
OOQFI&	OOQSS!##J	2 @G	z	1	1fI	2 
2	OOQ($i0	OOQSS!##h-()!< 
2	1s   2 D11E	c            
       J  a  ] tR tRt o RtR]3R ltR tR tR t	]
P                  P                  R 4       t]
P                  P                  R	]! R^4      4      R
 4       t]
P                  P                  RR4      R 4       t]
P                  P$                  ]
P                  P                  RR4      ]
P                  P                  R]P&                  ! R R^4      4      R 4       4       4       t]
P                  P                  R]P,                  ]P.                  34      ]
P                  P                  RR!4      ]
P                  P                  R]P&                  ! R"^^4      4      R 4       4       4       t]
P                  P                  R]P2                  ! R"^4      4      R 4       t]
P                  P                  ]
P                  P                  R]P&                  ! R R^4      4      R 4       4       t]
P                  P$                  ]
P                  P                  RR#4      ]
P                  P                  R]! ^4      4      R 4       4       4       tR tR tR t]
P                  PA                  ^4      ]
P                  PC                  R4      R 4       4       t"Rt#V t$R# )$TestMonteCarloHypothesisTesti  皙?Nc                   aaaa VVVV3R  l# )c                  :   < SP                  S! V R S/VB SR7      # )rA   dtype)rk  )r  kwdsr  rsrvs_inxps   *,r;   <lambda>6TestMonteCarloHypothesisTest.get_rvs.<locals>.<lambda>  s(    RZZ0V20VQU0V6; &0 &=rM   rW   )selfr  r  r  r  s   &ffffr;   get_rvs$TestMonteCarloHypothesisTest.get_rvs  s    = 	=rM   c                   a V3R  lpV# )c                    < SP                  WR 7      pSP                  W^R7      pV P                  V,          pW#V,          R,          ,          # )r   )r   
correctionrn  )r7   rw  rn   )rI   r   mvrb   r  s   &&   r;   r   =TestMonteCarloHypothesisTest.get_statistic.<locals>.statistic  sB    %Aq2AA!cz>!rM   rW   )r  r  r   s   &f r;   get_statistic*TestMonteCarloHypothesisTest.get_statistic  s    	" rM   c           	       a SP                  . RO4      pRV3R llpRpSP                  R 4      SP                  R!4      3p\        P                  P                  \        P                  P                  3p\
        P                  ! \        VR7      ;_uu_ 4        \        WVR R"R7       RRR4       R	p\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VR
R7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VR
R7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        VRV4       RRR4       \
        P                  ! \        VR7      ;_uu_ 4        SP                  R R.RR..4      p\        VR R.V4       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        SP                  . RO.4      p\        VR R .V4       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  R4       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VR#R7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VRR7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VR#R7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VRR7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P                  VRR7       RRR4       RpV3R lp \        W&SP                  4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL@; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELX; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELP; i  + '       g   i     EL; i  \         d.   p\        T4      P                  T4      '       g   Q h Rp?R# Rp?ii ; i)$      ?       @      @Nc                 (   < SP                  WR 7      # rf   rP   )rI   r   r  s   &&r;   stat@TestMonteCarloHypothesisTest.test_input_validation.<locals>.stat  s    7717((rM   r  r   c                     ^# r-   rW   rQ   s   &&&r;   r  DTestMonteCarloHypothesisTest.test_input_validation.<locals>.<lambda>      1rM   r   r   r   r   r   0`rvs` must be callable or sequence of callables.g      @c                     V # rV   rW   rI   s   &r;   r  r  !      arM   If `rvs` is a sequence...c                     V # rV   rW   r  s   &r;   r  r  &  r  rM   c                     V # rV   rW   r  s   &r;   r  r  &  r  rM   z`statistic` must be callable.)`n_resamples` must be a positive integer.r   r!   r"   r#   `alternative` must be in...r   r   z!Signature inspection of statisticc                 b   < SP                  \        P                  P                  V R 7      4      # )r)  )rk  r
   r   r   )rz   r  s   &r;   r   ?TestMonteCarloHypothesisTest.test_input_validation.<locals>.rvsB  s!    ::ejjnn$n788rM   r  r  r  rV   r.   r6  )r/   r6  r_   r2   )rk  zerosr
   r   r   r3   r4   r5   r   r9   r7   str
startswith)r  r  r~   r  r:   tempr   es   &f      r;   test_input_validation2TestMonteCarloHypothesisTest.test_input_validation  s    zz,'	) D "((6"23zz~~uzz~~.]]:W55T(<2F 6 /]]:W55T5::>>4cB 6 E]]:W55T5::>>4CH 6 E]]9G44T4. 5]]9G44::Bx"b23DTK#6= 5 .]]:W55::|n-DTK#=tD 6 2]]9G44T5::>>48 5 >]]:W55T5::>>4UK 6 >]]:W55T5::>>4VL 6 @]]:W55T5::>>4uE 6 @]]:W55T5::>>4vF 6 0]]:W55T5::>>4VL 6 6	9	.T0i 655 655 655 544444
 655
 544 655 655 655 655 655  	.q6$$W----	.s   Q$(Q8-(RR =(R4&S'&S;(S0(T'(T=(T,(U U $Q5	8R		R	 R1	4S	S	S-	0T	T	T)	,T=	 U	V"VVc           	     \  a V3R  lpRpSP                  . RO4      p\        S4      '       d(   \        V\        P                  P
                  V4       R# \        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P
                  V4       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        V\        P                  P
                  SP                  RR7       RRR4       R#   + '       g   i     Lp; i  + '       g   i     R# ; i)c                 &   < SP                  V 4      # rV   rP   )rI   r  s   &r;   non_vectorized_statisticWTestMonteCarloHypothesisTest.test_input_validation_xp.<locals>.non_vectorized_statisticJ  s    771:rM   z!`statistic` must be vectorized...Nr   Fr   r  )
rk  r   r   r
   r   r   r3   r4   r5   r7   )r  r  r  r:   r   s   &f   r;   test_input_validation_xp5TestMonteCarloHypothesisTest.test_input_validation_xpI  s    	 6L)B<<VUZZ^^5MN]]:W55VUZZ^^5MN 6]]:W55VUZZ^^RWWO 65 65555s   9&D2DD	D+	c                  a aa \         P                  P                  R 4      pSP                  VP	                  ^
R7      4      pV VV3R lo^ Sn        ^ Sn        RVRSRRRR/pS P                  \        P                  P                  \         P                  P                  R	4      SR
7      VR&   \        RR^/VB p\        SP
                  R4       \        SP                  ^4       S P                  \        P                  P                  \         P                  P                  R	4      SR
7      VR&   ^ Sn        \        RR^2/VB p\        SP
                  ^4       \        SP                  ^24       S P                  \        P                  P                  \         P                  P                  R	4      SR
7      VR&   ^ Sn        \        R/ VB p\        SP
                  ^4       \        SP                  R4       \        VP                  VP                  4       \        VP                  VP                  4       R# )   )p r)  c                    < V P                   ^8X  d   ^MV P                  ^ ,          p\        VSP                  4      Sn        S;P                  ^,          un        SP                  S4      ! WR7      # r  )r  rn   r$  
batch_sizecounterr  )rI   r   r  r  r   r  s   && r;   r   :TestMonteCarloHypothesisTest.test_batch.<locals>.statistic_  sX    ffkqwwqzJ#&z93G3G#HI "%%b)!77rM   r   r   r    r   r   Ti r  r   r$     NrW   )r6   rB   r   rk  standard_normalr  r  r  r
   r   r   r   r   r	   r   )	r  r  r+   rI   r  rJ   rK   res3r   s	   ff      @r;   
test_batch'TestMonteCarloHypothesisTest.test_batchX  s    ii##K0JJs***34	8
 	 	![)t\49 ll5::>>2993H3H3PUWlXU0a040Y&&-Y))1-ll5::>>2993H3H3PUWlXU	1b1D1Y&&+Y))2.ll5::>>2993H3H3PUWlXU	'$'Y&&*Y))40T[[1T[[1rM   r   c           	        \         P                  P                  R 4      p. ROp^dWA&   VP                  R4      P                  pR\        V4      9   d   RMRp\        \         V4      p\        W&4      pVP                  WGR7      p	\        P                  ! V	RVR7      p
VP                  WR7      p	V P                  V4      pV P                  \        P                  P                  W8VR	7      p\        WVR
RVR7      pVP                  V
P                  VR7      pVP                  V
P                   VR7      p\#        VP                  V4       \#        VP                   WP$                  R7       R# )it$ r  64float32r  )rz   r          )popmeanr   r  )r  r  Ti N  )r   r    r   r   Nr.   r/   r1   )r6   rB   r   rk  r  r  rE  r  r
   ttest_1sampr  r  r   r   r   r   r   r   r   )r  r   r  r+   rz   dtype_default	dtype_strdtype_npr  rI   r   r   r   r[   ref_statistic
ref_pvalues   &&&             r;   test_axis_dtype,TestMonteCarloHypothesisTest.test_axis_dtype~  s,    ii##G,
 

2,,!%]);!;I)	2y)& T:$$Q>JJqJ&&&r*	ll5::>>3lCqyT+0t= 

8#5#5U
CZZuZ=
}5

JYY?rM   r   c                "   \         P                  P                  R 4      pVP                  ^R7      p\        P
                  ! VRVR7      pVP                  V4      pV P                  V4      pV P                  \        P                  P                  W2R7      p\        WGWaR7      p\        VP                  VP                  VP                  4      4       \        VP                  VP                  VP                  4      V P                  R7       R# ))r)  r  r  r  r   N)r6   rB   r   r  r
   r  rk  r  r  r   r   r   r   r   r   r   )	r  r   r  r+   rI   r   r   r   r[   s	   &&&      r;   test_alternative-TestMonteCarloHypothesisTest.test_alternative  s     ii##H-R(2;?JJqM&&r*	ll5::>>3l6qyJrzz#--'@A

BJJszz$:KrM   rY   rn  c           	       a \         P                  P                  R 4      p\        P                  P                  V^VR7      p\        P                  ! V\        P                  P                  SR7      pV3R lpV P                  \        P                  P
                  V4      p\        WGVRRSR7      p\        VP                  VP                  4       SR8X  d/   \        VP                  VP                  V P                  R7       R
# SR	8X  d6   \        ^VP                  ,
          VP                  V P                  R7       R
# R
# )r  rY   rz   rA   r  c                 |   < \         P                  ! V \         P                  P                  R SR7      P                  # asymp)moder   )r
   ks_1sampr   cdfr   )rI   r   s   &r;   statistic1dGTestMonteCarloHypothesisTest.test_against_ks_1samp.<locals>.statistic1d  s+    >>!UZZ^^'.9;;D9ErM   r   Fr    r   r   r   r   r   N)r6   rB   r   r
   skewnormr   r  r   r  r  r   r   r   r   r   )	r  r   rY   r+   rI   r   r  norm_rvsr[   s	   &f&      r;   test_against_ks_1samp2TestMonteCarloHypothesisTest.test_against_ks_1samp  s    
 ii##H-NN#>>>!UZZ^^M	E <<

4qK+/E+68 	x'9'9:)#CJJdiiHF"AcjjL(//		J #rM   hypotestc                  a \         P                  P                  R 4      p\        P                  P                  V^VR7      pS! WRR7      pV3R lpV P                  \        P                  P
                  V4      p\        WXVRVR7      p	\        V	P                  VP                  4       \        V	P                  VP                  V P                  R7       R# )i	r  r  c                 *   < S! WR 7      P                   # rf   )r   )rI   r   r   s   &&r;   r   LTestMonteCarloHypothesisTest.test_against_normality_tests.<locals>.statistic  s    A)333rM   Tr   r   r   N)r6   rB   r   r
   r  r   r  r   r   r   r   r   r   )
r  r   r   rY   r+   rI   r   r   r  r[   s
   &f&&      r;   test_against_normality_tests9TestMonteCarloHypothesisTest.test_against_normality_tests  s    
 ii##H-NN3?A7	4 <<

4qI$+68 	x'9'9:

HOO$))DrM   c                   \         P                  P                  R 4      p\        P                  P                  V^VR7      p\        P                  ! V4      pR pV P                  \        P                  P
                  V4      p\        W6VRRR7      p\        VP                  VP                  4       \        VP                  VP                  V P                  R7       R# )i!M r  c                 D    \         P                  ! WR 7      P                  # rf   )r
   
normaltestr   r  s   &&r;   r   GTestMonteCarloHypothesisTest.test_against_normaltest.<locals>.statistic  s    ##A1;;;rM   Tr   r  r   N)r6   rB   r   r
   r  r   r	  r  r   r   r   r   r   r   )r  rY   r+   rI   r   r   r  r[   s   &&      r;   test_against_normaltest4TestMonteCarloHypothesisTest.test_against_normaltest  s     ii##H-NN3?##A&	< <<

4qI$+46 	x'9'9:

HOO$))DrM   c           	        \         P                  P                  R 4      p\        P                  P                  V^VR7      p\        P                  ! V\        P                  P                  4      pR pV P                  \        P                  P
                  V4      p\        W6VRRRR7      p\        VP                  VP                  4       \        VP                  VP                  V P                  R7       R# )	ir  c                 t    \         P                  ! V \         P                  P                  4      P                  # rV   )r
   cramervonmisesr   r  r   r  s   &r;   r  MTestMonteCarloHypothesisTest.test_against_cramervonmises.<locals>.statistic1d  s#    ''5::>>:DDDrM   r   Fr   r  r   N)r6   rB   r   r
   r  r   r  r   r  r  r   r   r   r   r   )r  rY   r+   rI   r   r  r  r[   s   &&      r;   test_against_cramervonmises8TestMonteCarloHypothesisTest.test_against_cramervonmises  s     ii##I.NN#>''5::>>:	E <<

4qK+/E+46 	x'9'9:

HOO$))DrM   	dist_namerX   c                  aa VV3R  lp\        4       ;_uu_ 4       pVP                  \        4       \        V^ R7      pRRR4       XP                  '       g   Q hVP
                  ^ ,          p\        P                  P                  R4      p\        P                  P                  V^dVR7      p\        P                  ! VS4      p	V	P                  p
V	P                  S,          ^d,          pV3R lpV P                  \!        \        S4      P                  V4      p\        4       ;_uu_ 4       pVP                  \        4       \#        WVRRRR	7      pRRR4       \%        XP                  V
4       \%        VP&                  V^V P(                  ,          R
7       R#   + '       g   i     ELg; i  + '       g   i     Le; i)c                    < \         P                  P                  R 4      p\        P                  P                  V ^dVR7      p\        P                  ! VS4      pVP                  VP                  S,          ,
          # )xr   )	r6   rB   r   r
   tukeylambdar   andersonr   critical_values)rY   r+   rI   r   r  rX   s   &   r;   fun?TestMonteCarloHypothesisTest.test_against_anderson.<locals>.fun  s`    ))''	2C!!%%ac%DA~~a3H%%(@(@(CCCrM   )x0Nr  r   c                 F   < \         P                  ! V S4      P                  # rV   )r
   r  r   )rI   r  s   &r;   r  GTestMonteCarloHypothesisTest.test_against_anderson.<locals>.statistic1d&  s    >>!Y/999rM   r   Fr   r  r   )r   filterRuntimeWarningr   successrI   r6   rB   r   r
   r  r   r  r   significance_levelr  rE  r   r   r   r   )r  r  rX   r  supsolrY   r+   rI   r   expected_stat
expected_pr  dist_rvsr[   s   &ff            r;   test_against_anderson2TestMonteCarloHypothesisTest.test_against_anderson  sF   	D
   CJJ~&sq/C ! {{{{ EE!Hii##I.!!!#C!@>>!Y/ **003C7
	: <<y 9 = =sC  CJJ~&"1#.D.3LC ! 	}5

JQtyy[A5 !  & ! s   #F.&F1F.	1G	c                    \         P                  P                  R 4      p\         P                  ! ^d4      p\	        W!P                  \         P
                  RRR7      pVP                  R8X  g   Q hR# )l   IL~QH(s Tr   r  g-C6?N)r6   rB   r   r  r   r7   r   )r  r+   rI   r[   s   &   r;   test_p_never_zero.TestMonteCarloHypothesisTest.test_p_never_zero3  sT     ii##$78HHSMq**bgg*.FDzzV###rM   c                   \         P                  P                  R 4      pVP                  RR7      VP                  ^R7      3pVP                  VP                  3pR p\        P
                  ! W#VRR7      p\        P                  ! V^ ,          V^,          .RR7      p\        VP                  VP                  4       \        VP                  VP                  RR7       R# )	   F:fmPr)  c                 F    \         P                  ! WVR 7      P                  # rf   r  rQ   s   &&&r;   r   FTestMonteCarloHypothesisTest.test_against_ttest_ind.<locals>.statisticA  s    ??1d3===rM   r   {Gz?r   Nr  r_   )
r6   rB   r   normalr
   r   r  r   r   r   r  r+   r~   r   r   r[   r   s   &      r;   test_against_ttest_ind3TestMonteCarloHypothesisTest.test_against_ttest_ind<  s    ii##$67zzvz&


(::jj#**$	> $$T	Cood1gQyr:s}}5

CJJT:rM   c                   \         P                  P                  R 4      pVP                  R	R7      VP                  R
R7      VP                  RR7      VP                  RR7      3pVP                  VP                  VP                  VP                  3pR p\        P
                  ! W#VRRR7      p\        P                  ! VRR/ p\        VP                  VP                  4       \        VP                  VP                  RR7       R# )r.  r)  c                 B    \         P                  ! VR V / P                  # r   )r
   f_onewayr   )r   r  s   $*r;   r   ETestMonteCarloHypothesisTest.test_against_f_oneway.<locals>.statisticP  s    >>43d3===rM   r   r   r   r   {Gz?r   Nro  )r.   e   )r.   f   )r.   g   r_   )
r6   rB   r   r2  r
   r   r8  r   r   r   r3  s   &      r;   test_against_f_oneway2TestMonteCarloHypothesisTest.test_against_f_onewayI  s    ii##$67


)3::8:+D


)3::8:+DFjj#**cjj#**<	> $$T	1:<nnd,,s}}5

CJJT:rM   z2Statistic may not depend on sample order on 32-bitc                  a \         P                  P                  R 4      oRpV3R lpV! ^d4      p\        P                  ! W2\         P
                  RVR7      p\         P                  ! VP                  VP                  8*  4      p\         P                  ! VP                  VP                  R,          8*  4      pWV8w  g   Q hVP                  V^,           V^,           ,          8X  g   Q hR# )l   U5<H rm  c                 b   < R \         P                  ! RR7      P                  V SR7      ,          # )r  gZd;O?)rW  r   )r
   	bernoullir   rz   r+   s   &r;   r   ITestMonteCarloHypothesisTest.test_finite_precision_statistic.<locals>.rvsb  s'    %044$S4QQQrM   r   )r   r    Ng     ?)
r6   rB   r   r
   r   rw  r   null_distributionr   r   )r  r    r   rI   r[   c0c1r+   s   &      @r;   test_finite_precision_statistic<TestMonteCarloHypothesisTest.test_finite_precision_statisticZ  s     ii##$45	R H$$QRVV1<> VVC))S]]:;VVC))S]]G-DDExxzzb1f{Q7777rM   rW   )	two-sidedr   r   )r   r   g      ࿩r   r   rL  r8  )r   logistic)%__name__
__module____qualname____firstlineno__r   r6   r  r  r  r  r3   markxslowr  parametrizer<  r  r  slowlinspacer  r
   skewtestkurtosistestr  r`   r  r  r(  r+  r4  r?  	fail_slowxfail_on_32bitrI  __static_attributes____classdictcell____classdict__s   @r;   r  r    s    D(, =@.DP [[#2 #2J [[VU2q\2@ 3@@ [[],LML NL& [[[[],?@[[S"++dC";<K = A K, [[Z%..%:L:L)MN[[],LM[[S"++b!Q"78E 9 N OE" [[S"))B"23E 4E" [[[[S"++dC";<E = E$ [[[[[*>?[[S%(+(B , @ (BT$;;" [[1[[ TU8 V 8rM   r  c                      a  ] tR tRt o R t]P                  P                  R 4       t]P                  P                  R 4       t	R t
R tRtV tR# )		TestPowerio  c                `
   \         P                  P                  R 4      p\        P                  pVP
                  VP
                  3pRpRp\        P                  ! \        VR7      ;_uu_ 4        \        W#VRR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        VRV4       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W!P
                  R3V4       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W!P
                  3V4       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W#R4       RRR4       R	p\        P                  ! \        VR7      ;_uu_ 4        \        W#V^R
7       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W#V\         P                  ! R^4      R
7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W#VRR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W#^
^.. RO34       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W#^
^.^^.3R. RO/R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        RW44       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W#VRR7       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W#VRR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W#VRR7       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W#VRR7       RRR4       R#   + '       g   i     EL; i  + '       g   i     ELf; i  + '       g   i     EL5; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELy; i  + '       g   i     ELP; i  + '       g   i     EL#; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL{; i  + '       g   i     ELR; i  + '       g   i     R# ; i)l   yB0 1 r   r   r   r   Nr  r   r  z3`significance` must contain floats between 0 and 1.significancez`kwargs` must be a dictionary)kwargsz+shape mismatch: objects cannot be broadcastrI   z`test` must be callablez(`n_resamples` must be a positive integerr   g      %@z"`batch` must be a positive integerr#   )ri   rk   )ri   r_   r,   )rk         i)r6   rB   r   r
   r  r2  r3   r4   r5   r   r9   rW  )r  r+   testr   n_observationsr:   s   &     r;   r  TestPower.test_input_validationp  sL   ii##$78zz3::&!D]]:W55$^< 6 E]]9G44$n- 5]]9G44$V,n= 5 .]]:W55$~6 6]]:W55$U# 6 H]]:W55$^!< 6]]:W55$^"++b!:LM 6 2]]9G44$^I> 5 @]]:W55$r2h56 6]]:W55$r2hR13	:JK 6 ,]]9G44$, 5 =]]:W55$^= 6]]:W55$^> 6 7]]:W55$^37 6]]:W55$^48 65Y 655 544444 655555 655555 544 655555 544 655555 655555s   0P-P'P,.Q 2Q-Q(($Q<:R7R$6R8=S8S 3S40T+TP	P)	,P=	 Q	Q%	(Q9	<R	R!	$R5	8S		S	 S1	4T	T	T-	c                  a \         P                  P                  R 4      pV3R lo^ Sn        ^ Sn        \        S^
RR7      p\         P                  P                  R 4      p\        R/ VBRVP                  R^/B p\        SP                  R4       \        SP                  ^4       \         P                  P                  R 4      p^ Sn        \        R/ VBRVP                  R^2/B p\        SP                  ^4       \        SP                  ^24       \         P                  P                  R 4      p^ Sn        \        R/ VBRVP                  RR/B p\        SP                  ^4       \        SP                  R4       \        VP                  VP                  4       \        VP                  VP                  4       R# )r  c                    < V P                   ^8X  d   ^M
\        V 4      p\        VSP                  4      Sn        S;P                  ^,          un        \
        P                  ! V ^ VR7      P                  # r  )r  ra   r$  r  r  r
   r  r   )rI   r   r  rh  s   && r;   rh  "TestPower.test_batch.<locals>.test  sS    ffks1vJ!*doo>DOLLAL$$Q5<<<rM   r   )rh  ri  r    r   r$   NrW   )	r6   rB   r   r  r  r   r   r2  r   )r  r+   r  rJ   rK   r  rh  s   &     @r;   r  TestPower.test_batch  sO    ii##K0	=
 bdCii##K05t5515T\\4(T__a(ii##K06t6626T\\2&T__b)ii##K08t8848T\\1%T__d+TZZ,TZZ,rM   c                  aaa \         P                  P                  R 4      p\         P                  ! ^ R.4      oRV3R llp\         P                  ! . RO4      R\         P
                  3,          pR. RO/p\         P                  ! . RO4      p\        P                  ! W!P                  W5VR7      p. pV Fl  pV Fc  p	VR,           FS  oS FJ  oRVV3R llp
\        P                  ! WP                  V	VR7      pVP                  VP                  4       KL  	  KU  	  Ke  	  Kn  	  \         P                  ! WvP                  P                  4      p\        VP                  VR	RR
7       R# )l   x7'\皙?c           
         < \         P                  ! S\        \        ^V P                  ^,           4      4      4      p\
        P                  ! WVVR7      # )r-   )r   r   )r6   expand_dimsr8   r<  r  r
   r  )rI   r   r   popmeans_expandedpopmeanss   &&& r;   rh  *TestPower.test_vectorization.<locals>.test  sC     "xuQQR
?S9T U$$Q{*.0 0rM   r4  r   r;  rd  re  c                 8   < \         P                  ! V SVSR 7      # )r:  )r
   r  )rI   r   alternative_i	popmean_is   &&r;   test2+TestPower.test_vectorization.<locals>.test2  s!    #(#4#4Q	AN$P PrM   rc  r1  )r   r   Nr^   )ri   r   rT  r   rl   rM  )r;  r  皙?r   )r6   rB   r   r   rk  r  r
   r   r2  appendrp   rn   r   )r  r+   rh  nxre  rd  r[   r   significance_inx_irz  tmprx  ry  rt  s   &           @@@r;   test_vectorizationTestPower.test_vectorization  s     ii##N3 88QH%	0 ZZ-.q"**}=!AB zz":;kk$

B!') *N%+M%:%:M%-	P P $kk%T7EG

399- &. &;  + jjiioo. 			3T=rM   c                   \         P                  P                  R 4      p\        P                  pVP                  ^
^dRR7      pVP                  VP                  3p\         P                  ! . RO4      p\        P                  ! W$W5R7      p\         P                  ! VR\         P                  3,          VP                  P                  4      p\        VP                  VRR7       R# )	   &( r)  r;  rc  r4  r   N)r.   ri   )r;  r|  r   )r6   rB   r   r
   r  integersr2  rk  r   ro   r  rn   r   )r  r+   rh  ri  r   rd  r[   s   &      r;   test_ttest_ind_nullTestPower.test_ttest_ind_null  s     ii##O4b#G<jj#**$zz"34kk$^O|ArzzM'BCIIOOT		<d;rM   c                   \         P                  P                  R 4      p. RO. RO.. R	O. R
O..pR. RO/p^
.^..pRR.p\        P                  ! \        P
                  VP                  VWSR7      p\        VP                  VRR7       R# )r  r  r;  r|  rv  r   N)gv?g]NbJ?g6;?)gOt]?g7gLڷ?g0Dҗ?)gVL[?g;c?g.H&?)g#*3)?glk?g5i ?)r   rn  r   )r6   rB   r   r
   r   r  r2  r   )r  r+   r   re  ri  rd  r[   s   &      r;   test_ttest_1samp_power TestPower.test_ttest_1samp_power  s    ii##O4 5464467
 _-$d|kk%++SZZ'3D		3T2rM   rW   N)rO  rP  rQ  rR  r  r3   rS  rV  r  r  r  r  r\  r]  r^  s   @r;   ra  ra  o  sX     69p [[!- !-F [[%> %>N<3 3rM   ra  c                     a  ] tR tRt o RtR tR t]P                  P                  R]
P                  P                  ]
P                  P                  .4      ]P                  P                  R. R:O4      R	 4       4       t]P                  P                  R]
P                  P                  ]
P                  P                  .4      ]P                  P                  R
R]P                   ! ^4      ^,          3R;R]P"                  ! ^^4      3.4      R 4       4       tR t]P                  P)                  4       R 4       tR t]P                  P                  RR<4      R 4       t]P                  P                  RR<4      R 4       t]P                  P                  RR<4      R 4       tR t]P                  P7                  4       ]P                  P                  RR=4      R 4       4       t]P                  P(                  ]P                  P                  RR<4      R 4       4       t]P                  P                  RR<4      R 4       tR t]P                  P                  RR<4      R 4       t ]P                  P7                  4       ]P                  P                  RR>4      R 4       4       t!R. R?OR. R@ORRRR R!R"R#R$R%R&R'R(/t"R. RAOR. RBORR)RR*R!R+R#R,R%R-R'R./t#]P                  P7                  4       ]P                  P                  R/]"]#34      R0 4       4       t$]P                  P(                  ]P                  P                  R1RC4      R2 4       4       t%]P                  P                  R3RD4      R4 4       t&]'! ^ 4      ^. 3]'! ^4      ^. REO. RFO.3]'! ^4      ^. REO. RFO^^..3.t(]P                  P                  R5](4      R6 4       t)]P                  PU                  ^4      R7 4       t+R8t,V t-R9# )GTestPermutationTesti  r*  c                N    \         P                  P                  R 4      V n        R# )l   F N)r6   rB   r   r+   )r  s   &r;   setup_method TestPermutationTest.setup_method  s    99(()<=rM   c                
   R  pRp\         P                  ! \        VR7      ;_uu_ 4        \        . RO^.3V4       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        RV4       RRR4       \         P                  ! \        VR7      ;_uu_ 4        \        ^V4       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VR	R
7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VR	R7       RRR4       Rp\         P                  ! \        VR7      ;_uu_ 4        \        . RO. RO3VRR7       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELg; i  + '       g   i     EL8; i  + '       g   i     EL	; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL|; i  + '       g   i     ELM; i  + '       g   i     EL; i  + '       g   i     R# ; i)c                 F    \         P                  ! W3V4      P                  # rV   r  rQ   s   &&&r;   r  :TestPermutationTest.test_permutation_test_iv.<locals>.stat"  s    ??A640:::rM   z2each sample in `data` must contain two or more ...r   Nz6`data` must be a tuple containing at least two samplesr   r   r   z `permutation_type` must be in...r   )permutation_typer   r   r  r   r!   r"   r#   r  r  r(   r)   r*   r,   r  r2   )r3   r4   r5   r   r9   )r  r  r:   s   &  r;   test_permutation_test_iv,TestPermutationTest.test_permutation_test_iv   s   	; G]]:W55i!-t4 6 K]]:W55T4( 6]]9G44Q% 5 /]]:W55i3TD 6 5]]:W55i3T.46 6 E]]:W55i3TcJ 6 >]]:W55i3TuM 6 >]]:W55i3TvN 6 @]]:W55i3TG 6 @]]:W55i3TH 6 0]]:W55i3TvN 6 A]]9G44i3TyI 54W 655 655444 655 655
 655 655 655 655 655 655 544s   L*L)#L=M!M%$M9'N*N!-N50O	3O6O1L&	)L:	=M	M"	%M6	9N
	N	!N2	5O		O	O.	1P	rA   r  pairingsindependentc           	     "  a	 V P                   P                  ^
4      pV P                   P                  ^
4      pV	3R lo	^ S	n        ^ S	n        RRRVRR/p\        P
                  ! W43S	3R^RV! ^ 4      /VB p\        S	P                  R	4       \        S	P                  ^4       ^ S	n        \        P
                  ! W43S	3R^2RV! ^ 4      /VB p\        S	P                  ^4       \        S	P                  ^24       ^ S	n        \        P
                  ! W43S	3RRRV! ^ 4      /VB p\        S	P                  ^4       \        S	P                  R4       \        VP                  VP                  4       \        VP                  VP                  4       R
# )ri   c                   < V P                   ^8X  d   ^M
\        V 4      p\        VSP                  4      Sn        S;P                  ^,          un        \
        P                  ! WR7      \
        P                  ! WR7      ,
          # r  )r  ra   r$  r  r  r6   r7   )rI   rR   r   r  r   s   &&& r;   r   1TestPermutationTest.test_batch.<locals>.statistic`  s[    ffks1vJ#&z93G3G#HI "771(2771+@@@rM   r    r   r  r   Tr$   rA   r  N)r+   rB   r  r  r
   r   r   r   )
r  r  rA   rI   rR   r  rJ   rK   r  r   s
   &&&      @r;   r  TestPermutationTest.test_batchV  s    HHOOBHHOOB	A
 	 	t%79Id$%%qfi Lq L3??LFJLY&&-Y))1-	%%qfi Lr L3??LFJLY&&+Y))2.	%%qfi Lt L3??LFJLY&&*Y))40T[[$++.T[[$++.rM   zpermutation_type, exact_sizec           	     |   V P                   P                  ^4      pV P                   P                  ^4      pR pRVRR/p\        P                  ! WE3V3R^RV! ^ 4      /VB p\	        VP
                  P                  ^4       \        P                  ! WE3V3/ VB p\	        VP
                  P                  V4       R# )r/   c                 h    \         P                  ! WR 7      \         P                  ! WR 7      ,
          # rf   r   rQ   s   &&&r;   r   8TestPermutationTest.test_permutations.<locals>.statistic      771(2771+@@@rM   r  r   Tr    rA   N)r+   rB   r
   r   r   rF  rz   )	r  r  
exact_sizerA   rI   rR   r   r  r[   s	   &&&&     r;   test_permutations%TestPermutationTest.test_permutations  s     HHOOAHHOOA	A #$4d$$$aVY KA K2>q/KEIKS**//3$$aVY?$?S**//<rM   c           
        R ^ r!^^	RrTp\         P                  ! W4,           V4      V8  g   Q h\        P                  P	                  VR7      p\        P                  P	                  VR7      pWg3pR p	RRRRR^dR	VR
V/p
\        W3RV/V
B p\        W3R\        P                  /V
B pVP                  VP                  8X  g   Q h\        VP                  VP                  RR7       R# )r   i]  r)  c                 h    \         P                  ! WR 7      \         P                  ! WR 7      ,
          # rf   r   rQ   s   &&&r;   r   NTestPermutationTest.test_randomized_test_against_exact_both.<locals>.statistic  r  rM   r   Tr  r  r$   r   r+   r    r;  r   N)r   binomr
   r   r   r   r6   infr   r   r   r  r   r+   r~  nypermutationsrI   rR   r~   r   r  r[   rK   s   &            r;   'test_randomized_test_against_exact_both;TestPermutationTest.test_randomized_test_against_exact_both  s     "1S !U}}RWb)L888JJNNN#JJNNN#t	A d$6m[%Ft 'L '!%'LRVVLtL}}...

DKKd;rM   c           
        R Rr!^^RrTp^V,          V8  g   Q h\         P                  P                  VR7      p\         P                  P                  VR7      pWg3pR p	RRRRR	^dR
VRV/p
\        W3RV/V
B p\        W3R\        P
                  /V
B pVP                  VP                  8X  g   Q h\        VP                  VP                  RR7       R# )r   Ni }  r)  c                 >    \         P                  ! W,
          VR 7      # rf   r   rQ   s   &&&r;   r   QTestPermutationTest.test_randomized_test_against_exact_samples.<locals>.statistic  s    7715t,,rM   r   Tr  samplesr$   r   r+   r    r;  r   )	r
   r   r   r   r6   r  r   r   r   r  s   &            r;   *test_randomized_test_against_exact_samples>TestPermutationTest.test_randomized_test_against_exact_samples  s    
 %dS!2u"u|###JJNNN#JJNNN#t	- d$6	m[%Ft 'L '!%'LRVVLtL}}...

DKKd;rM   c           
       a R V P                   r!^^RrTp\        P                  ! V4      V8  g   Q h\        P                  P                  VR7      p\        P                  P                  VR7      oV.pV3R lp\        P                  ! V4      p	RRRRR^dR	VR
V/p
\        Wy3RV/V
B p\        Wy3R\        P                  /V
B pVP                  VP                  8X  g   Q h\        VP                  VP                  RR7       R# )rL  i@  r)  c                 @   < \         P                  ! V S4      ^ ,          # r   r
   pearsonrrI   rR   s   &r;   r  TTestPermutationTest.test_randomized_test_against_exact_pairings.<locals>.statistic1d  s    >>!Q'**rM   r   Tr  r  r$   r   r+   r    r;  r   N)r+   r   	factorialr
   r   r   r   re  r   r6   r  r   r   r   )r  r   r+   r~  r  r  rI   r~   r  r   r  r[   rK   rR   s   &            @r;   +test_randomized_test_against_exact_pairings?TestPermutationTest.test_randomized_test_against_exact_pairings  s     'S !U  $|333JJNNN#JJNNN#s	+  44[A	d$6	m[%Ft 'L '!%'LRVVLtL}}...

DKKd;rM   r   c                  a V P                   P                  ^^R7      pV P                   P                  ^^^R7      p\        P                  ! W#SRR7      pV3R lp\	        W#3V\
        P                  RV P                   R7      p\        VP                  VP                  V P                  R7       \        VP                  VP                  V P                  R7       R	# )
r1   rz   ry   )rz   rx   ry   exact)r   r  c                 J   < \         P                  ! WR SR7      P                  # r  )r
   ks_2sampr   rI   rR   r   s   &&r;   r  >TestPermutationTest.test_against_ks_2samp.<locals>.statistic1d  s!    >>!W.9;;D9ErM   r   r    r   r+   r   N)r+   r2  r
   r  r   r6   r  r   r   r   r   )r  r   rI   rR   r   r  r[   s   &f     r;   test_against_ks_2samp)TestPermutationTest.test_against_ks_2samp  s     HHOO!O,HHOOO3>>!KgN	E v{+4$((D 	x'9'9		J

HOO$))DrM   c                   V P                   P                  ^^R7      pV P                   P                  ^^R7      pRRRRRR/pWA,          p\        P                  ! W#VR7      pR p\	        W#3V\
        P                  WP                   R7      p\        VP                  VP                  V P                  R7       \        VP                  VP                  V P                  R7       R	# )
r1   r  r   r   rL  r  c                 B    \         P                  ! W4      P                  # rV   r
   ansarir   r  s   &&r;   r  <TestPermutationTest.test_against_ansari.<locals>.statistic1d      <<%///rM   r  r   N)r+   r2  r
   r  r   r6   r  r   r   r   r   )	r  r   rI   rR   alternative_correspondencealternative_scipyr   r  r[   s	   &&       r;   test_against_ansari'TestPermutationTest.test_against_ansari  s     HHOO!O,HHOO!O, '-i&/&1;&@" 7C<<2CD	0 v{+6HHF 	x'9'9		J

HOO$))DrM   c           
        \         P                  P                  R	^ V P                  R7      p\         P                  P                  R	RV P                  R7      p\         P                  ! W#^VR7      pR p\        W#3VR\        P                  V^V P                  R7      p\        VP                  VP                  V P                  R7       \        VP                  VP                  V P                  R7       R# )
r/   rz   rx   rA   r|  r:  c                 F    \         P                  ! WVR 7      P                  # rf   )r
   mannwhitneyur   rQ   s   &&&r;   r   @TestPermutationTest.test_against_mannwhitneyu.<locals>.statistic!  s    %%a6@@@rM   T)r   r    r   r   r+   r   N)r/   r6  r.   )r
   uniformr   r+   r  r   r6   r  r   r   r   r   )r  r   rI   rR   r   r   r[   s   &&     r;   test_against_mannwhitneyu-TestPermutationTest.test_against_mannwhitneyu  s     MM9!$((KMM9$TXXN%%aL	A vyT+-66{$%4885 	x'9'9		J

HOO$))DrM   c                   \         P                  P                  ^^V P                  R7      p\         P                  P                  ^^^V P                  R7      p\         P                  ! WRR7      pR p\        W3V\        P                  RV P                  R7      p\        VP                  VP                  V P                  R7       \        VP                  VP                  V P                  R7       R	# )
r1   )rz   ry   rA   )rz   rx   ry   rA   r  r%   c                 F    \         P                  ! WR R7      P                  # 
asymptoticr%   )r
   cramervonmises_2sampr   r  s   &&r;   r  9TestPermutationTest.test_against_cvm.<locals>.statistic1d2  s!    --a5ACCL9MrM   r   r  r   N)r
   r   r   r+   r  r   r6   r  r   r   r   r   )r  rI   rR   r   r  r[   s   &     r;   test_against_cvm$TestPermutationTest.test_against_cvm+  s    JJNNNBJJNNqNI--a7C	M
 v{+4$((D 	x'9'9		J

HOO$))DrM   r   c           
     \   \         P                  P                  R 4      pVP                  ^R7      pVP                  RR7      pVP                  RR7      pW4V3pR pR p\        P                  ! V4      p	\        P                  ! V4      p
\         P
                  ! VR4      p\         P
                  ! VR4      p\         P
                  ! VR4      pV	! WWR7      pV
! WWR7      pRRRVRR	R
RRV P                  /p\        Wg3R\         P                  /VB p\        Wg3RR/VB p\        VP                  WP                  R7       \        VP                  VP                  V P                  R7       \        VP                  VRR7       \        VP                  VP                  RR7       R# )l   Y}y!dh r)  c                  >    \         P                  ! V !  P                  # rV   )r
   kruskalr   r~   s   *r;   r  ITestPermutationTest.test_vectorized_nsamp_ptype_both.<locals>.statistic1dO  s    ==$'111rM   c                  >    \         P                  ! V !  P                  # rV   )r
   r  r   r  s   *r;   pvalue1dFTestPermutationTest.test_vectorized_nsamp_ptype_both.<locals>.pvalue1dR  s    ==$'...rM   r   r   Fr   r   r   r  r  r+   r    r   r   gQ?r   r   N)r-   r/   r.   )r.   r-   r1   )r.   r/   r/   )r.   r/   r.   r  )r6   rB   r   r   re  ro   r+   r   r  r   r   r   r   )r  r   r+   rI   rR   rg   r~   r  r  r   r   x2rA  z2expected_statisticexpected_pvaluer  r[   rK   s   &&                 r;    test_vectorized_nsamp_ptype_both4TestPermutationTest.test_vectorized_nsamp_ptype_both=  sj    ii##$78JJQJ JJIJ&JJIJ&ay	2	/  44[A	11(; __Q	*__Q	*__Q	*&rr= 7 eVT=)"M5$((DtMbffMMLtLtL 	'9		Jt~~DIIF

O$?

DKKd;rM   c                  a \         P                  P                  R^ V P                  R7      p\         P                  P                  RRV P                  R7      pR pR pV3R lp\        P
                  ! V4      pV! W#^R7      pV^ ,          p	V^,          p
RRR	^R
SRRRV P                  R\        P                  /p\        W#,
          3V3/ VB p\        W#3V3/ VB p\        VP                  VP                  V P                  R7       SR8w  d"   \        VP                  WP                  R7       \        VP                  WP                  R7       \        VP                  VP                  V P                  R7       R# )r/   r  r|  c                 F    \         P                  ! V R R7      P                  # r   r  r
   wilcoxonr   )rg   s   &r;   statistic_1samp_1dETestPermutationTest.test_against_wilcoxon.<locals>.statistic_1samp_1dv  s    >>!8BBBrM   c                 F    \         P                  ! WR R7      P                  # r  r  r  s   &&r;   statistic_2samp_1dETestPermutationTest.test_against_wilcoxon.<locals>.statistic_2samp_1dz  s    >>!F;EEErM   c                 4   < \         P                  ! WSR 7      # )r  )r
   r  r  s   &&r;   test_1d:TestPermutationTest.test_against_wilcoxon.<locals>.test_1d}  s    >>!K@@rM   r   r   Fr   r   r  r  r+   r    r   rL  N)r/   r7  r.   )r
   r  r   r+   r   re  r6   r  r   r   r   r   r   )r  r   rI   rR   r  r  r  rh  r   r%  r&  r  rJ   rK   s   &f            r;   test_against_wilcoxon)TestPermutationTest.test_against_wilcoxonm  s9    MM9!$((KMM9$TXXN	C	F	A //81% a[
eVQ{"Iudhhrvv'  (:CdC(:CdC 	TYYG+%DNNM		JZii@T[[tyyArM   c           
     d   V P                   P                  ^ ^^
R7      pR
W"^ 8H  &   RR lpV! V4      ^
Rrep\        P                  ! WEWaR7      p\        P                  ! V3VRR\
        P                  V P                   VR7      p\        VP                  VP                  V P                  R7       R	# )r   r)  c                 8    \         P                  ! V ^ 8  VR7      # )r   r   r6   r   r  s   &&r;   r   =TestPermutationTest.test_against_binomtest.<locals>.statistic  s    66!a%d++rM   rn  r  Tr  )r   r  r    r+   r   r   Nr_   r   )
r+   r  r
   r   r   r6   r  r   r   r   )	r  r   rI   r   krb   rW  r   r[   s	   &&       r;   test_against_binomtest*TestPermutationTest.test_against_binomtest  s     HHa,q&	
	, A,Ca??1D$$aT96?13TXX1<> 	

HOO$))DrM   c                  a V P                   P                  ^R7      pWP                   P                  ^R7      ,           o\        P                  ! VSRR7      pV3R lp\	        V3VR\
        P                  V P                   R7      p\        VP                  VP                  V P                  R7       \        VP                  VP                  V P                  R7       R# )	r7  r)  r  r%   c                 J   < \         P                  ! V SR R7      P                  # r  )r
   
kendalltaur   r  s   &r;   r  @TestPermutationTest.test_against_kendalltau.<locals>.statistic1d  s    ##Aq>HHHrM   r  )r  r    r+   r   N)r+   r2  r
   r  r   r6   r  r   r   r   r   )r  rI   r   r  r[   rR   s   &    @r;   test_against_kendalltau+TestPermutationTest.test_against_kendalltau  s    HHOOO#Q''##Aq9	I t[:+-66txxA 	x'9'9		J

HOO$))DrM   c           	        a V3R  lp\         P                  P                  R4      pVP                  ^4      R8  P                  \        4      pVP                  ^4      RV,          ,           R8  P                  \        4      o\
        P                  P                  VS4      ^,          p\        V3VR\         P                  VVR7      p\
        P                  ! WQR7      p\        VP                  V^,          4       R# )c                 J   < \         P                  ! V ^8H  S^8H  ,          4      # r  r   r  s   &r;   r   @TestPermutationTest.test_against_fisher_exact.<locals>.statistic  s    6616a1f-..rM   l   	(yM4 g333333?g      ?r  )r  r    r   r+   r  N)r6   rB   r   astypefloatr
   contingencycrosstabr   r  fisher_exactr   r   )	r  r   r   r+   rI   tabr[   rK   rR   s	   &&      @r;   test_against_fisher_exact-TestPermutationTest.test_against_fisher_exact  s    	/ ii##$78ZZ]S ((/ZZ]T!V#c)11%8((A.q1tY+-66{#&( !!#?

DG,rM   c           
        V P                   P                  RR7      pV P                   P                  RR7      pV P                   P                  RR7      p\        P                  ! W!R7      p\        P                  ! W1R7      p\        P                  ! WAR7      pV^ ,          pW#V3pR pR p\        P
                  ! V4      p\        P
                  ! V4      p	V! \        P                  ! V!  RV/ p
V	! \        P                  ! V!  RV/ pRRRVRR	R
RR^ /p\        WV3R\        P                  /VB p\        WV3RR/VB p\        VP                  WP                  R7       \        VP                  VP                  V P                  R7       \        VP                  WP                  R7       \        VP                  VP                  RR7       R# )r.   r)  r   c                  H    \         P                  ! V R RR7      P                  # )Tr  rankedr&   )r
   page_trend_testr   r  s   *r;   r  LTestPermutationTest.test_vectorized_nsamp_ptype_samples.<locals>.statistic1d  s"    ((d0<>>GiHrM   c                  H    \         P                  ! V R RR7      P                  # )Tr  r  )r
   r  r   r  s   *r;   r  ITestPermutationTest.test_vectorized_nsamp_ptype_samples.<locals>.pvalue1d  s"    ((d0799?@rM   r   r   Fr   r   r  r  r+   r    rw   r   r   r   N)r.   r1   r/   )r-   r1   r/   )r.   r1   r-   )r+   rB   r
   rankdatar   re  r6   broadcast_arraysr   r  r   r   r   r   )r  r   rI   rR   rg   r~   r  r  r   r   r  r  r  r[   rK   s   &&             r;   #test_vectorized_nsamp_ptype_samples7TestPermutationTest.test_vectorized_nsamp_ptype_samples  s{    HHOOO+HHOOO+HHOOO+NN1(NN1(NN1(aDay	H	@  44[A	11(;&(;(;T(BNN ""5"5t"<H4H eVT=)"Jq:tMbffMMLtLtL'9		Jt~~DIIF

O))D

DKKd;rM   rI   rR   expected_lessrp  expected_2sidedg?expected_Pr_gte_S_meang&_?r  g      @expected_avggd~$I"@expected_stdglu?gd?gd?gYo5 ?g     @@@g{C@gDmFA@casec           	     L   VR,          pVR,          pVR,          pVR,          pVR,          pVR,          pVR,          pVR,          p	R	 p
\         P                  P                  4       ;_uu_ 4       pVP                  \        R
4       \        W#3V
\         P                  RR7      p\        W#3V
\         P                  RR7      pRRR4       \        XP                  W@P                  R7       \        VP                  VRR7       \        XP                  VRR7       \        VP                  P                  4       VRR7       \        VP                  P                  4       V	RR7       VP                  pVP                  P                  4       p\        VP                  4      p\         P                  ! \         P                   ! VP                  V,
          4      \         P                   ! W,
          4      8  4      V,          p\        VV4       R#   + '       g   i     ELV; i)a.  
Results above from SAS PROC NPAR1WAY, e.g.

DATA myData;
INPUT X Y;
CARDS;
1 1
1 2
1 3
1 4
2 1.5
2 2
2 2.5
ods graphics on;
proc npar1way AB data=myData;
    class X;
    EXACT;
run;
ods graphics off;

Note: SAS provides Pr >= |S-Mean|, which is different from our
definition of a two-sided p-value.

rI   rR   r  r"  r#  r$  r%  r&  c                 B    \         P                  ! W4      P                  # rV   r  r  s   &&r;   r  7TestPermutationTest.test_with_ties.<locals>.statistic1d0  r  rM   z$Ties preclude use of exact statisticr   )r    r   rL  Nr   g|=r   gư>)r6   testingr   r  UserWarningr   r  r   r   r   r   rF  r7   r   ra   r   r   )r  r'  rI   rR   r  r"  r#  r$  r%  r&  r  r#  r[   rK   Sr7   rb   Pr_gte_S_means   &&                r;   test_with_ties"TestPermutationTest.test_with_ties
  s   8 II!"67_-01!%&>!?N+N+	0 ZZ))++sJJ{$JK"A6;BFF/57C#QFKRVV0;=D	 , 	'9		J

M>_5A..335|$O..224lN MM$$))+%%&rvvc&;&;D&@A"$&&. 1 2234.>' ,++s   2AHH#	zalternative, expected_pvaluec                   a . R	Op. R
OoRpV3R lp\        V3VR\        P                  VR7      p\        VP                  W@P
                  R7       \        VP                  VRR7       R# )a  
Results above from R cor.test, e.g.

options(digits=16)
x <- c(1.76405235, 0.40015721, 0.97873798,
       2.2408932, 1.86755799, -0.97727788)
y <- c(2.71414076, 0.2488, 0.87551913,
       2.6514917, 2.01160156, 0.47699563)
cor.test(x, y, method = "spearm", alternative = "t")
g?c                 F   < \         P                  ! V S4      P                  # rV   )r
   	spearmanrr   r  s   &r;   r  DTestPermutationTest.test_against_spearmanr_in_R.<locals>.statistic1db  s    ??1a(222rM   r  )r  r    r   r   gvIh%<=r   N)g@9?gY,?gOQ?g[iY@g|?g鈶BE)gQGn@gU?gz˱@?gmGA6@gB @g˭?)r   r6   r  r   r   r   r   )r  r   r  rI   r  r  r[   rR   s   &&&    @r;   test_against_spearmanr_in_R/TestPermutationTest.test_against_spearmanr_in_RH  s_    (10/	3 t[:+-66{L 	'9		J

O%@rM   r$   c                    \         P                  ! \        R R7      ;_uu_ 4        \        \        P
                  ! . ROV4      4       RRR4       R#   + '       g   i     R# ; i)z`batch` must be positive.r   Nr,   )r3   r4   r5   rq   r   _batch_generator)r  r$   s   &&r;   test_batch_generator_iv+TestPermutationTest.test_batch_generator_ivk  s9    ]]:-HII--i?@ JIIIs   #AA#	ziterable, batch, expectedc                T    \        \        P                  ! W4      4      pWC8X  g   Q hR # rV   )rq   r   r8  )r  iterabler$   r   gots   &&&& r;   test_batch_generator(TestPermutationTest.test_batch_generatort  s#     ;//@ArM   c                *   . ROp. ROpR p\         P                  ! W3VRRR7      pVP                  VP                  VP                  rvp^\
        P                  ! WuR,
          8  4      ,          \        V4      ,          pYhu;8X  d	   R	8X  g   Q h Q hR# )
r-   c                 <    \         P                  ! W4      ^ ,          # r   r  r  s   &&r;   r   FTestPermutationTest.test_finite_precision_statistic.<locals>.statistic  s    >>!'**rM   Fr  )r   r  r*  N)r-   r.   r1   r/   )r.   r1   r7  r  gUUUUUU?)r
   r   r   r   rF  r6   r   ra   )	r  rI   rR   r   r[   rr   null	correct_ps	   &        r;   rI  3TestPermutationTest.test_finite_precision_statisticz  s    
 	+ $$aVY56@B--S5J5J4t5y011CI=	)c)))))rM   r*   N)r  r  r  )r  r  rM  )r_   r.   )r8  r-   r0   )r   r.   g      @)o   k   rl   r   r=  j   m   l   )	rH  rK  rI  b   i   r>  n   rM  r   ))r   g?)r   gOO?)rL  g<OO?)r_   r   r   r-   r.   )r/   r1   r6  ).rO  rP  rQ  rR  r   r  r  r3   rS  rU  r6   rB   rC   r   r  r   r  r  r  r  rV  r  r  r  r  r  r  rT  r  r  r  r	  r  r   
tie_case_1
tie_case_2r/  r5  r9  r<  batch_generator_casesr>  rZ  rI  r\  r]  r^  s   @r;   r  r    s`    D>
2Jl [[^bii.C.C.0ii.C.C.E F[[/CE"/EF"/J [[^bii.C.C.0ii.C.C.E F[[;)7+<+<Q+?+BC/,gmmAq.ABDE=	EF=4<2 [[< <2<: [[],LME NE& [[],LME NE* [[],LME NE"E$ [[[[VW-*< . *<\ [[[[],LM#B N #BJ [[],LME NE,E" [[],LM- N-$ [[[[VW-'< . '<V |S-!<#S*L& (NGEJ >C!<#\*L& )^XGJ [[[[Vj*%=>:? ? :?x [[[[;>?A	? 
A< [[Wg.A /A $Ah2.#AhIy+AB#AhIy1a&+IJL [[8244 [[1* *rM   r  c                     \         P                  ! . RO\        R7      p \         P                  ! V 4      p\	        4       p^ p\
        P                  ! V 4       FX  pV^,          p\         P                  ! WARR 4      pTP                  \        V Uu. uF  p\        V4      NK  	  up4      4       KZ  	  \         P                  ! \        \        V 4      ^,
          4       Uu. uF7  p\        P                  ! \!        WR 4      \!        W^,           R 4      4      NK9  	  up4      p\#        W74       \#        \        V4      V4       R# u upi u upi )r/   r  N)r/   r.   r1   r_   )r6   r   intcumsumsetr   _all_partitions_concatenatedsplitaddr8   	frozensetprodr<  ra   r   r  r   r   )rb   ncall_partitionsr  partition_concatenatedpartitioningrX   r   s           r;    test_all_partitions_concatenatedr`    s    	#&A	1BUNG"-"J"J1"M1xx 63B@5!E1)A,!EFG #N
 ww!&s1vax2!0A  c!B%j#a!g,?!02 3H #^$h/ "F2s   E =Efun_namec           	      x  aa \         P                  P                  R 4      oSP                  ^
R7      oV3R lpRRS3RSRR/RRS3RSR	R
/RRSRV//pR^d/p\        \        V 4      pW ,          pVP                  V4       V3R lpV! RRVRR/VB  V! RRVRR/VB  R pV! RRVRR/VB  V! RRVRR/VB  R# )l   r: r)  c                 F   < \         P                  P                  V SR 7      # )r   )r
   r   r   rD  s   &r;   r   &test_parameter_vectorized.<locals>.rvs  s    zz~~4c~::rM   r   r~   r+   r&   r>   r   r  r  r   r   r   r    c                    < V P                   ^8  g    \        P                  ! V S4      '       g   Q h\        P                  ! WR7      # r  )r  r6   r>  r7   )rI   r   r   s   &&r;   r   ,test_parameter_vectorized.<locals>.statistic  s3    vvzR^^Av6666wwq$$rM   r   r   NTc                 T    V P                   ^8X  g   Q h\        P                  ! V 4      # r  )r  r6   r7   r  s   &r;   r   rf    s     vv{{wwqzrM   FrW   )r6   rB   r   rE  r
   r   )	ra  r   fun_optionscommon_optionsr  optionsr   r+   r   s	   &      @@r;   test_parameter_vectorizedrk    s   
 ))


/CZZRZ F; &E3!)<!9%	5#(:I(G%&%'E	GK
 $S)N
%
"C#GNN>"% 8)8888)888 8)8889)999rM   c                   &   a  ] tR tRt o R tRtV tR# )TestMonteCarloMethodi  c                   R p\         P                  P                  R4      p\        P                  ! \
        VR7      ;_uu_ 4        \        P                  ! VP                  VR7       RRR4       R#   + '       g   i     R# ; i)z.Use of `rvs` and `rng` are mutually exclusive.ir   )r   r+   N)r6   rB   r   r3   r4   r5   r
   MonteCarloMethod)r  r:   r+   s   &  r;   test_rvs_and_random_state.TestMonteCarloMethod.test_rvs_and_random_state  sO    Bii##H-]]:W55""szzs; 6555s   #A33B	rW   N)rO  rP  rQ  rR  rp  r\  r]  r^  s   @r;   rm  rm    s     < <rM   rm  )r=   r>   r?   rO  )gQ7@gHzS@)g\(<@g=
ףpU@)gHz'@@gQV@)r   rn  r-   )r   r   r   )Br3   numpyr6   numpy.testingr   r   r   scipy._lib._utilr   scipy._lib._array_apir   scipy._lib._array_api_no_0dr   r	   scipyr
   r   scipy.optimizer   scipy.statsr   r   r   r   scipy.stats._resamplingr   r<   rS  rU  rL   rc   ru   rV  r[  r   tests_Ritemsr   r   r   tests_against_itself_1sampr   tests_against_itself_2sampr   r  r  r  r!  r&  r,  r2  rB  rK  rY  r]  rg  rt  filterwarningsr  r  r  ra  r  r`  rk  rm  rW   rM   r;   <module>r     s!     J J ) * H    L L - -<8~ #AB+; , C;" #AB> C>2 #AB+D%=1(: 2 , C(:V AB#ABO C C O0 N."
 +W]]_=C >C.7 t12 &t*D#T+ 
 +399;=#= #L &s*C1  +399;=,= ,^ G\#:;!Q(> ) <>. EF#AB!Q(> ) C G>, #AB( C( #AB6 C6"2& /!T;  < 2 ;<#AB; C =;.!& m]%CD- E-2 +.+" , /"." +  , 4 #AB> C >> 45!> 6 !>H=*u8 u8pe3 e3Ps	* s	*x0* NP:P:B< <rM   