+
    nDjJn                       ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
HtHtHtHtHtHtHt ^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IH t H!t!H"t"H#t# ^ RI$Hu H%t% ].t&]! ] 4       ! R R4      4       t']! ]!4       ! R R4      4       t(]! ]#4       ! R R4      4       t)]! ]"4       ! R R4      4       t*R t+]PX                  P[                  R. RO4      R 4       t. ! R R4      t/R# )    N)assert_allcloseassert_equal)rng_integers)is_numpymake_xp_test_casexp_default_dtypexp_sizearray_namespace_xp_copy_to_numpyis_lazy_arrayeager_warns)xp_assert_closexp_assert_equal)array_api_extra)statsspecial)skip_xp_backends)root)	bootstrapmonte_carlo_testpermutation_testpowerc                   	  a  ] tR t^t o ]! RRR7      R 4       tR t]P                  P                  R. R>O4      ]P                  P                  R
. R?O4      R 4       4       t
]P                  P                  R. R>O4      R 4       t]P                  P                  R. R>O4      ]P                  P                  R
. R?O4      ]P                  P                  RRR.4      R 4       4       4       t]P                  P                  ]P                  P                  R4      ]P                  P                  R. R>O4      R 4       4       4       t. R@Ot]P                  P                  R]4      R 4       tR tR tRRRRR	R/t]P                  P                  ]P                  P                  R]P+                  4       4      R 4       4       tRRRR/t]P                  P                  ]P                  P                  R]P+                  4       4      R 4       4       t]P                  P                  R. R>O4      ]P                  P                  R
^ ^.4      ]P                  P                  RRR .4      R! 4       4       4       t]P                  P                  R"4      ]P                  P                  R. R>O4      ]P                  P                  R
^ ^.4      R# 4       4       4       t]P                  P                  R. R>O4      R$ 4       t]P                  P                  R. RAO4      R% 4       tR& t]P                  P                  R'^ R(.4      R) 4       t]P                  P                  R*4      ]P                  P                  R. R>O4      R+ 4       4       tR, t ]P                  P	                  R-R.R7      ]P                  P                  R/R0R1.4      R2 4       4       t!]P                  P                  R3. RBO4      ]P                  P                  R
. R?O4      R4 4       4       t"]P                  P                  R
. R?O4      R5 4       t#]P                  P                  ]P                  P                  R. R>O4      R6 4       4       t$]P                  P                  ]P                  PK                  R74      R8 4       4       t&]P                  P	                  RR9.R:7      R; 4       t'R<t(V t)R=# )CTestBootstrapnumpyzNumPy does not raisereasonc                   a R SP                    2p\        P                  ! \        VR7      ;_uu_ 4        \	        SP                  . RO4      3V3R l4       RRR4       R#   + '       g   i     R# ; i)zWhen using array library matchc                 &   < SP                  V 4      # Nmeanxxps   &[/data/cameron/venvs/s3viz/lib/python3.14/site-packages/scipy/stats/tests/test_resampling.py<lambda>7TestBootstrap.test_bootstrap_iv_other.<locals>.<lambda>   s    "''!*    N         )__name__pytestraises	TypeErrorr   asarray)selfr'   messages   &f r(   test_bootstrap_iv_other%TestBootstrap.test_bootstrap_iv_other   sJ    -bkk];]]9G44rzz),.0DE 5444s   #A""A3	c           	     
   VP                  . RO4      pRp\        P                  ! \        VR7      ;_uu_ 4        \	        \        4       VP                  4       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W!P                  ^.4      3VP                  4       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W!P                  . RO4      3VP                  RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W!P                  R	R
7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  R R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  R R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  R	R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  ^
R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  ^ R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        V3VP                  RR7       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELQ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELO; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELK; i  + '       g   i     R# ; i)!r-   z(`data` must contain at least one sample.r   Nz>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rngr,   r-   r.   r/      )r4   r1   r2   
ValueErrorr   tupler$   r3   )r5   r'   sampler6   s   &&  r(   test_bootstrap_ivTestBootstrap.test_bootstrap_iv!   sc   I&<]]:W55egrww' 6 S]]:W55vzz1#/9 6 S]]:W55vzz,78"''$O 6 E]]:W55fgg&9 6 /]]:W55vis3 6 6]]:W55vi4@ 6 B]]:W55vie< 6 B]]:W55vif= 6 @]]:W55vi6 6 @]]:W55vi7 6 (]]:W55vi8 6 T]]:W55vi2> 6 J]]:W55via8 6 A]]9G44vii8 54i 655 655 655 655 655 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   P((P<+Q6Q$<Q8RR R4S$S,S04T<TT,(P9	<Q	Q!	$Q5	8R		R	 R1	4S	S	S-	0T	T	T)	,T=	rL   basic
percentileBCarB   c           
     h   \         P                  P                  ^ 4      pVP                  ^
^^4      p\	        VP                  V4      3VP                  RV^ V^dR7      p\         P                  P                  ^ 4      p\	        VP                  V4      3V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)rJ   rL   random_staterB   rF   )rJ   rL   rB   rF   r^   )nprandomRandomStaterandr   r4   r$   r   confidence_intervallowhighstandard_error)r5   rL   rB   r'   rQ   r&   res1res2s   &&&&    r(   test_bootstrap_batch"TestBootstrap.test_bootstrap_batch\   s     ii##A&HHRR "**Q-)277$v&'dEii##A&"**Q-)277"V"#G 	0044d6N6N6R6RS0055t7O7O7T7TU++T-@-@Ar+   c                  aa	a
a \         P                  P                  ^ 4      p^dpSP                  VP	                  V4      4      o
SP                  VP	                  V4      4      oRV3R llo	RV	V
V3R llpSP                  S
P                  ^ ,          4      p\        V3V^ R7      p\        S
S3S	R^ R7      p\        VP                  P                  VP                  P                  4       \        VP                  P                  VP                  P                  4       \        VP                  VP                  4       R# )r   c                 D   < SP                  W,
          ^,          VR7      # )r.   rA   r#   r&   yrB   r'   s   &&&r(   my_statistic9TestBootstrap.test_bootstrap_paired.<locals>.my_statisticv   s    77AC!8$7//r+   c                 <   < SV ,          pSV ,          pS! W#4      pV# r"    )irB   abresro   r&   rn   s   &&   r(   my_paired_statistic@TestBootstrap.test_bootstrap_paired.<locals>.my_paired_statisticy   s$    !A!Aq$CJr+   rP   T)r:   rQ   N)r_   r`   ra   r4   rb   arangeshaper   r   rc   rd   re   rf   )r5   rL   r'   rQ   nrw   rs   rg   rh   ro   r&   rn   s   &&f      @@@r(   test_bootstrap_paired#TestBootstrap.test_bootstrap_pairedn   s     ii##A&JJsxx{#JJsxx{#	0	 	 IIaggaj!!2:!QdB0044d6N6N6R6RS0055t7O7O7T7TU++T-@-@Ar+   r:   TFc           
       a \         P                  P                  ^ 4      pRV3R llpRpWr,          pVP                  V4      p	VP                  V4      p
VP                  V4      pSP	                  V	4      SP	                  V
4      SP	                  V4      rp	\        WV3WcV^ ^ ^dR7      pVP                  P                  VP                  P                  R,           8X  g   Q h. ROpWV&   \        V4      pSP                  SP                  W4      V4      p	SP                  SP                  W4      V4      p
SP                  SP                  W4      V4      p\        WV3WcV^ V^dR7      p\        V4      pVP                  V4       SP                  VP                  P                  V4      pSP                  VP                  P                   V4      pSP                  VP                  V4      p\#        VP                  P                  V4       \#        VP                  P                   V4       \#        VP                  V4       R# )r   c                    < SP                  WR 7      SP                  WR 7      ,           SP                  W#R 7      ,           # rA   r#   )r&   rn   zrB   r'   s   &&&&r(   ro   =TestBootstrap.test_bootstrap_vectorized.<locals>.my_statistic   s4    7717(27717+@@27717CXXXr+   )r:   rL   rQ   rB   rF   Nry   )
         )d   )r-   r-   r-   )r_   r`   ra   rb   r4   r   bootstrap_distributionr|   rf   rV   broadcast_toreshapelistpoprc   rd   re   r   )r5   rL   rB   r:   r'   rQ   ro   r|   	n_samplesr&   rn   r   rg   r   rh   result_shape
ref_ci_lowref_ci_highref_ci_standard_errors   &&&&f              r(   test_bootstrap_vectorized'TestBootstrap.test_bootstrap_vectorized   s    ii##A&	Y K	HHYHHYHHY**Q-A

1a!LQC9++11&&,,v56 	7 6 !.OOBJJq2E:OOBJJq2E:OOBJJq2E:!LTs< E{__T%=%=%A%A<P
ood&>&>&C&C\R "0C0C\ R0044jA0055{C++-BCr+   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      w  rxVP                  4       p	\        VP                  V4      3VP                  RWR7      p
\        R/ V
BRV/B p\        VP                   P"                  VP                  V4      RR	7       \        VP                   P$                  VP                  V4      RR	7       \        V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P+                  V4      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P+                  ^V,
          4      4      RR	7       R# )l   )ICbX    )locscalesizer^   ffffff?)dfr   r   )
confidence)data	statisticrF   rL   rQ   rD   gMb@?rtolga2U0*3?atolrF   rM   alternativelessgreaterNrr   )r_   r`   default_rngr   normrvstlenr$   semintervalstddictr4   r   r   rc   rd   re   rf   updateppf)r5   rL   r'   rQ   r   alphadistref_lowref_highref_seconfigrv   s   &&&         r(   test_bootstrap_against_theory+TestBootstrap.test_bootstrap_against_theory   s   
 ii##$78zz~~!14c~Jww#d)A+2774=		$P MMUM;BJJt,."''t#.9&959//33RZZ5HtT//44bjj6JQUV**BJJv,>TJdq3?@M&M5MfM//44

488E?3$	@ 	dq3?@P&P5PiP//33

488AeG#45D	Br+   zmethod, ref_low, ref_highc                &   VP                  . RO4      p\        V3VP                  RV^ R7      p\        VP                  P
                  VP                  V4      RR7       \        VP                  P                  VP                  V4      RR7       R# )r   i@B )rF   rL   rQ   g{Gzt?r   N)r   r         )@r   g+@            "   2   Q   Y   y         )r4   r   r$   r   rc   rd   re   )r5   rL   r   r   r'   r&   rv   s   &&&&&  r(   test_bootstrap_against_R&TestBootstrap.test_bootstrap_against_R   sr    " JJ ; <bgg76qQ//33RZZ5HuU//44bjj6JQVWr+   c                   VP                  . R
O4      pVP                  . RO4      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VP                  VP                  VP                  4      4      p	VP                  VP                  VP                  4      4      p
VP                  VP                  VP                  4      4      pRpW,
          \        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,
          # r   )r   skew)r&   rn   rB   s1s2s   &&&  r(   r   ?TestBootstrap.test_multisample_BCa_against_R.<locals>.statistic   s%    A)BA)B7Nr+   l   tgy4rZ   )rL   rJ   rQ   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ÿ)
r4   r_   r`   r   r   r   r$   stackrc   abs)r5   r'   r&   rn   r   rQ   	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_R,TestBootstrap.test_multisample_BCa_against_R   s^    JJ = >JJ H I
	 ii##$67OOQFIg*-38	ooqfi,/S://1&)E(+6 GGBHHY%B%BCD	ggbhh{'F'FGH''"((7#>#>?@ 	  +S^;
#/Y?'Y7 E!!!d"""8}t###r+   c           	     (  a SP                  . RO4      pSP                  . RO4      pRV3R llpW2.p\        P                  ! WT4      pRpRpVP                  p	^dp
\        P
                  ! WTWxWS4      w   r\        VSP                  R4      4       R# )	      $@c                 V   < SP                  WR 7      SP                  WR 7      ,
          # r   r#   )r   rn   rB   r'   s   &&&r(   r   HTestBootstrap.test_BCa_acceleration_against_reference.<locals>.statistic2  $    7717(27717+@@@r+   r   ge{?N)	r   g      ;@g      ?@g      D@g      G@g      I@g      J@g      Z@g     @b@)g      0@g      7@g      C@g     W@g     X@g     a@g     h@r   rz   )r4   r   r   r   _resampling_bca_intervalr   )r5   r'   rn   r   r   r   rv   rB   r   theta_hat_brJ   _a_hats   &f           r(   'test_BCa_acceleration_against_reference5TestBootstrap.test_BCa_acceleration_against_reference(  s     JJFGJJ<=	A vood.00!//0;BH1rzz*>?@r+   i  i  zmethod, expectedc                   \         P                  P                  R 4      p^dpRpRp\        P                  ! ^^R7      p\        VP                  4       4      p	Rp
VP                  W3VR7      p\        VP                  V4      3VP                  VV^2VR	VR7      pVP                  pVP                  V^ ,          V	8  W^,          8  ,          4      pW8X  g   Q h\        P                  ! \        V4      V
V4      P                  pVR8  g   Q hR# )
i8   ?r   r   i  r   r^   )r   rD   rF   rJ   rL   rB   rQ   皙?Nrz   )r_   r`   r   r   r   floatr$   r   r   r4   rc   count_nonzero	binomtestintpvalue)r5   rL   expectedr'   rQ   r}   rF   rD   r   	stat_truen_replicationsr   rv   cici_contains_truer   s   &&&&            r(   #test_bootstrap_against_itself_1samp1TestBootstrap.test_bootstrap_against_itself_1sampD  s
    ii##G, zzaq)$))+&	 xxn0sxCD)+"$'')9$/ %! $$ ++RUY->9RSuCT,UV+++ %5!6!13396 	||r+   i|  iz  c                  a \         P                  P                  ^ 4      p^dp^xpRpRpRV3R llp	\        P                  ! ^ ^R7      p
\        P                  ! R^R7      p\        V
P                  4       VP                  4       ,
          4      pRpV
P                  W3VR7      pVP                  W3VR7      p\        SP                  V4      SP                  V4      3V	VV^2VR
VR7      pVP                  pSP                  V^ ,          V8  VV^,          8  ,          4      pVV8X  g   Q h\        P                  ! \        V4      VV4      P                  pVR8  g   Q hR	# )r   r   r   c                 \   < SP                  WR 7      pSP                  WR 7      pW4,
          # r   r#   )data1data2rB   mean1mean2r'   s   &&&  r(   my_statBTestBootstrap.test_bootstrap_against_itself_2samp.<locals>.my_stat  s+    GGEG-EGGEG-E= r+   r   r     r   )r   rD   rF   rJ   rL   rB   r^   Nrz   ry   )r_   r`   ra   r   r   r   r$   r   r   r4   rc   r   r   r   r   )r5   rL   r   r'   rQ   n1n2rF   rD   r  dist1dist2r   r   r  r  rv   r   r   r   s   &&&f                r(   #test_bootstrap_against_itself_2samp1TestBootstrap.test_bootstrap_against_itself_2sampo  sP    ii##A&	! 

q*

s!,%**,56	 		3#	F		3#	FE*BJJu,=>"))9$/ %%(* $$ ++RUY->9rRSuCT,UV8+++ %5!6!13396 	||r+   dtypefloat32float64c           
     f  aa R ^ /V3R llpV3R lp\         P                  P                  ^ 4      pVP                  ^^4      P	                  S4      pVP                  ^^4      P	                  S4      p	VP                  ^^4      P	                  S4      p
\        SP                  V4      SP                  V	4      SP                  V
4      3VRV^dV^ R7      p\        WV
3VRV^dV^ R7      pSR8X  d   RMRp\        VP                  P                  SP                  VP                  P                  4      VR	7       \        VP                  P                  SP                  VP                  P                  4      VR	7       \        VP                  SP                  VP                  4      VR	7       R
# )rB   c                 2   <a  \        V V3R  lV 4       4      # )c              3   J   <"   T F  pSP                  VSR 7      x  K  	  R# 5i)rA   Nr#   ).0rW   rB   r'   s   & r(   	<genexpr>STestBootstrap.test_bootstrap_vectorized_3samp.<locals>.statistic.<locals>.<genexpr>  s!     EfrwwvDw11s    #sum)rB   r   r'   s   d*r(   r   @TestBootstrap.test_bootstrap_vectorized_3samp.<locals>.statistic  s    EEEEr+   c                     < V  F  pVP                   ^8X  d   K  Q h	  \        P                  ! \        R V  4       4      SR7      # )r-   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r#   )r  rW   s   & r(   r  VTestBootstrap.test_bootstrap_vectorized_3samp.<locals>.statistic_1d.<locals>.<genexpr>  s     !CdF++--ds   r  )ndimr_   r4   r  )r   rW   r  s   * r(   statistic_1dCTestBootstrap.test_bootstrap_vectorized_3samp.<locals>.statistic_1d  s;    {{a''' ::c!Cd!CC5QQr+   T)r>   rB   rF   rL   rQ   Fr  ư>+=r   N)r_   r`   ra   rb   astyper   r4   r   rc   rd   re   rf   )r5   rL   rB   r  r'   r   r  rQ   r&   rn   r   rg   rh   r   s   &&&ff         r(   test_bootstrap_vectorized_3samp-TestBootstrap.test_bootstrap_vectorized_3samp  sh   	F! 	F	R ii##A&HHQN!!%(HHQN!!%(HHQN!!%("**Q-A

1F"t$C &A/ !LU"FK 	)tu0044

4#;#;#?#?@t	M0055

4#;#;#@#@A	N++RZZ8K8K-LSWXr+   z'Failure is not concerning; see gh-14107c                V  a RV3R llpR p\         P                  P                  R4      pVP                  R	4      p\        SP	                  V4      3VRV^dRV^ R7      p\        V3VRV^d^
V^ R7      p	\        VP                  P                  SP	                  V	P                  P                  4      4       \        VP                  P                  SP	                  V	P                  P                  4      4       \        VP                  SP	                  V	P                  4      4       R# )
r   c                 (   < SP                  WR 7      # r   r#   r&   rB   r'   s   &&r(   r   @TestBootstrap.test_bootstrap_vectorized_1samp.<locals>.statistic  s    7717((r+   c                 L    V P                   ^8X  g   Q hV P                  ^ R7      # r-   rA   )r  r$   r&   s   &r(   r  CTestBootstrap.test_bootstrap_vectorized_1samp.<locals>.statistic_1d  s"    66Q;;66q6>!r+   l   2 TN)r>   rB   rF   rJ   rL   rQ   Fr   )r.   r/   )
r_   r`   r   r   r4   r   rc   rd   re   rf   )
r5   rL   rB   r'   r   r  rQ   r&   rg   rh   s
   &&&f      r(   test_bootstrap_vectorized_1samp-TestBootstrap.test_bootstrap_vectorized_1samp  s    	)	"
 ii##J/JJv"**Q-)9D%(VL!|D%(6qJ0044

4#;#;#?#?@	B0055

4#;#;#@#@A	C++RZZ8K8K-LMr+   c           
        VP                  RR4      pVR8X  d   \        P                  ! RR7      ;_uu_ 4        Rp\        \        P
                  WBR7      ;_uu_ 4        \        V.VP                  VR7      p\        VP                  P                  VP                  VP                  4      4       \        VP                  P                  VP                  VP                  4      4       RRR4       RRR4       Mw\        V.VP                  VR7      p\        VP                  P                  VP                  R4      4       \        VP                  P                  VP                  R4      4       \        XP                  VP                  R	4      R
R7       R#   + '       g   i     L; i  + '       g   i     LL; i)#   g     @r\   ignore)invalidz0The BCa confidence interval cannot be calculated)r    r'   rK   N        g-q=r   )r1  )fullr_   errstater   r   DegenerateDataWarningr   r$   r   rc   rd   r4   nanre   r   rf   )r5   rL   r'   r   msgrv   s   &&&   r(   test_bootstrap_degenerate'TestBootstrap.test_bootstrap_degenerate  s)   wwuf%U?X..H !<!<COO#THbggfEC#C$;$;$?$?BFFAST#C$;$;$@$@"**RVVBTU P /. THbggf=CC3377F9KLC3388"**V:LM**BJJrNG PO /.s$   &F/BF	+F/F,'F//F?	c           	        \         P                  P                  R 4      p\        P                  ! ^^R7      pVP                  ^dVR7      p\        VP                  V4      3\        P                  V^d\         P                  P                  R4      R7      p\        V3\        P                  V^d\         P                  P                  R4      RR7      p\        VP                  P                  VP                  VP                  P                  4      4       \        VP                  P                  VP                  VP                  P                  4      4       \        VP                  VP                  VP                  4      4       R# )l   E<1

 r   r   i[%  rL   rF   rQ   F)rL   rF   rQ   r>   N)r_   r`   r   r   r   r   r   r4   r   r   rc   rd   re   rf   )r5   rL   r'   rQ   r   r   rv   refs   &&&     r(   test_bootstrap_gh15678$TestBootstrap.test_bootstrap_gh15678  s    ii##O4zzaq)xxSsx3D)+UZZTWII11$79 FII11$7EK//33

3#:#:#>#>?	A//44

3#:#:#?#?@	B**BJJs7I7I,JKr+   c           	        \         P                  P                  R 4      p\        P                  ! ^^R7      pVP                  ^dVR7      p\         P                  ! V4      pVP                  V4      p\        V3VP                  R^d\         P                  P                  R4      R7      p\        VP                  P                  VP                  V4      4       \        V) 3V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)r_   r`   r   r   r   r   minr4   r   r   rc   rd   maxr   re   )r5   r'   rQ   r   r   true_minrv   rh   s   &&      r(   test_bootstrap_min TestBootstrap.test_bootstrap_min  s    ii##$45zzaq)xxSsx366$<zz$3II11$79//33RZZ5IJ4%266%SYY2248:00444d6N6N6S6ST00555t7O7O7S7STr+   additional_resamplesr  c           
        \         P                  P                  R 4      pVP                  ^dR7      pRpTpWQ,           p\         P                  P                  R4      p\        P                  ! VP                  V4      3VP                  WSRRR7      p\        P                  ! VP                  V4      3VP                  WcRRVR	7      p\         P                  P                  R4      p\        P                  ! VP                  V4      3VP                  WsRRR7      p	\        VP                  P                  VP                  V	P                  P                  4      R
R7       \        VP                  P                  VP                  V	P                  P                  4      R
R7       \        VP                  VP                  V	P                  4      R
R7       R# )l    ]4M r   r  l   mdpi4 r   r[   )rF   rQ   rD   rL   r   r\   )rF   rQ   rD   rL   rM   r"  r   N)r_   r`   r   r   r   r4   r$   r   rc   rd   re   rf   )
r5   rG  r'   rQ   r&   r  r	  n3rv   r>  s
   &&&       r(   test_re_bootstrapTestBootstrap.test_re_bootstrap
  sn    ii##$45JJCJ !&ii##$67oorzz!}.R/3LJoorzz!}.R/3E/24 ii##$67oorzz!}.R/3EC 	//33

3#:#:#>#>?"	$ 	//44

3#:#:#?#?@"	$ 	**BJJs7I7I,JQVWr+   zSensitive to machine precisionc                t   \         P                  P                  R 4      p\        P                  ! ^^R7      pVP                  VP                  ^dVR7      4      3p\        WRP                  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       VP                  VP                  P                  4      '       d   VP                  P                  ^ 8  g   Q hVP                  V	P                  P                  4      '       d   V	P                  P                  ^ 8  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   rQ   rB   rD   r   r   r   r   r   r   r"  r   z`alternative` must be one ofr   z	ekki-ekkiNrz   rr   )r_   r`   r   r   r   r4   r   r   r   r   r   r   rc   re   rd   isinfr1   r2   rU   )
r5   rL   r'   rQ   r   r   r   r   lgs
   &&&       r(   test_bootstrap_alternative(TestBootstrap.test_bootstrap_alternative'  s    ii##$78zzaq)

488#S8ABD466sDOO;f;s;dq1=>OOPfPtPPOOSfStSS--22A4I4I4N4N"	$--1113H3H3L3L"	$xx--1122q7L7L7P7PST7TTTxx--22338M8M8R8RUV8VVV]]:-KLLOO>f>+> MLLLs   H&&H7	c                   R	p\         P                  P                  R4      pVP                  VR7      p\        \        P
                  ! VP                  V4      VR7      4      p\        VR
,          4       FA  pVRVR3,          p\         P                  ! WFR
R7      p\        WqP                  V4      4       KC  	  \        \        P
                  ! VP                  V4      ^VR7      4      p	\        VP                  V	RR7      V4       R# )r/      Zt rI  r'   .NNNrA   )rJ   r'   Nr/   rS         rz   )r_   r`   r   nextr   _jackknife_resampler4   rangedeleter   r   concat)
r5   r'   r|   rQ   r&   rn   rs   slcr   y2s
   &&        r(   test_jackknife_resample%TestBootstrap.test_jackknife_resample?  s    ii##J/JJEJ"00A2FGuRy!A CAI,CyyB/HCH!56 " +11"**Q-qRPQ		"2	.2r+   array_api_strictzTest uses ... + fancy indexingrng_namera   r   c           
        \        \        P                  V4      pV! R 4      pV! R 4      p^
pRp\        P                  P                  R4      pVP	                  VP                  V4      4      p	\
        P                  ! WWBR7      p
\        V4       FP  pV
RVR3,          pVP	                  \        V^ VR,          VR,          4      4      pV	RV3,          p\        W4       KR  	  R# )l   1V rT  )rQ   r'   .rV  NrW  rz   )
getattrr_   r`   r   r4   r   _bootstrap_resampler]  r   r   )r5   re  r'   rng_genrng1rng2rF   r|   rQ   r&   rn   rs   r`  jsr   s   &&&            r(   test_bootstrap_resample%TestBootstrap.test_bootstrap_resampleP  s     "))X.z"z"ii##J/JJszz%()++AL{#A CAI,CLq%)U2YGHBbzHC* $r+   scorec                V   R	p\         P                  P                  R4      pVP                  V4      p\        V4      p\        P
                  ! VP                  WgR7      VP                  WR7      R
VR7      pR p	V	! WaR
R7      ^d,          p
\        WP                  WR7      RR7       R# )r   l   Q,? r  )rB   r'   c                 N    \         P                  ! \        P                  W V4      # r"   )r_   apply_along_axisr   percentileofscore)rt   ro  rB   s   &&&r(   vectorized_pos>TestBootstrap.test_percentile_of_score.<locals>.vectorized_post  s    &&u'>'>OOr+   rA   V瞯<r   N)r         rz   )r_   r`   r   r   r   _percentile_of_scorer4   r   )r5   ro  rB   r'   r|   rQ   r&   r  prt  p2s   &&&&       r(   test_percentile_of_score&TestBootstrap.test_percentile_of_scorei  s     ii##J/JJu $,,RZZZ-G-/ZZZ-K24=	P A2.s2::b:6UCr+   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
! WVWqR7      pV! WVWqR7      p	\        W4       R# )c                 .   a  \        V 3R  lV 4       4      # )c              3   D   <"   T F  qP                  S4      x  K  	  R # 5ir"   r#   )r  rW   rB   s   & r(   r  LTestBootstrap.test_vectorize_statistic.<locals>.statistic.<locals>.<genexpr>  s     <tV{{4((ts    r  rB   r   s   d*r(   r   9TestBootstrap.test_vectorize_statistic.<locals>.statistic  s    <t<<<r+   c                  L   < V  F  pVP                   ^8X  d   K  Q h	  S! V R^ / # )r-   rB   )r  )r   rW   r   s   * r(   r  <TestBootstrap.test_vectorize_statistic.<locals>.statistic_1d  s/    {{a''' d+++r+   rA   N)r   _vectorize_statisticr_   r`   ra   rb   r   )r5   rB   r  
statistic2rQ   r&   rn   r   rg   rh   r   s   &&        @r(   test_vectorize_statistic&TestBootstrap.test_vectorize_statistic{  s    
	=	, !55lC
ii##A&HHQ1HHQ1HHQ1q,!-#r+   c           
       a \         P                  P                  R 4      pRpSP                  VP                  ! VRR	/ 4      pV3R lp\        V3WaR
R^VR7      pSP                  ^R.4      pSP                  VP                  P                  P                  V8  VP                  P                  P                  V8  ,          ^ R7      pSP                  V^Z8  4      '       g   Q hS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:       ?r   c           	      l   < SP                  SP                  WR 7      SP                  W^R7      .4      # )rA   rB   
correction)r   r$   r   )r   rB   r'   s   &&r(   r   =TestBootstrap.test_vector_valued_statistic.<locals>.statistic  s9    88RWWTW5VVDVBD E Er+   '  )rL   rB   rF   rJ   r^   rA   N)r-   r  )r   r   rz   r.   r   )r.   r   r  )r_   r`   r   r4   normalr   r   rc   rd   Tre   allr|   rf   r   )	r5   rL   r'   rQ   paramsrW   r   rv   countss	   &&f      r(   test_vector_valued_statistic*TestBootstrap.test_vector_valued_statistic  si    ii##J/CJJ@Z@A	E 	9"$(#G QH%!!3#:#:#>#>#@#@6#I%(%<%<%A%A%C%Cf%L#N'( " * vvfl####vvfm$$$$&&**00H<<<&&++11X===!!''8333))//>AAAr+   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\        W2V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)r$   var)r&   rn   rB   xmymcovs   &&&   r(   concordanceGTestBootstrap.test_vector_valued_statistic_gh17715.<locals>.concordance  sn    BB9%!m*;<BB4HCGdaeeDk 9RWN JKKr+   c                 ^   < W,           pW,           p\         P                  ! S! WVV4      4      # r"   )r_   
nan_to_num)tptnfpfnrB   actualr   r  s   &&&&&  r(   r   ETestBootstrap.test_vector_valued_statistic_gh17715.<locals>.statistic  s'    WFwH==Vt!DEEr+   c                 H   < S! . VOV N5!  \         P                  R 3,          # ).)r_   newaxis)rB   argsr   s   $*r(   statistic_extradimNTestBootstrap.test_vector_valued_statistic_gh17715.<locals>.statistic_extradim  s#    )d)D)"**c/::r+   T)rQ   r:   rv  r   N)rS   r   r   r.   )r.   r-   r.   r-   )r   rY  r   r   )r   rY  r/   r   )r      r-   r   )
r_   r`   r   arrayr  r   r   rc   rd   re   )r5   rQ   r  r   rv   r>  r  r   s   &     @@r(   $test_vector_valued_statistic_gh177152TestBootstrap.test_vector_valued_statistic_gh17715  s     ii##$67	L	F
	; 	
 xx~c$GiS>//33A6//33%	A//44Q7//445	Br+   cupy)np_only
exceptionsc                   \         P                  P                  R 4      pVP                  VP                  R4      4      pVP                  VP                  R4      4      pR p\        P
                  ! W43V4       \        P
                  ! VP                  VP                  3V^R7       Rp\        P                  ! \        VR7      ;_uu_ 4        \        P
                  ! W4R,          3V4       RRR4       \        P
                  ! W4R	,          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                  # r   r   	ttest_indr   r&   rn   rB   s   &&&r(   r   .TestBootstrap.test_gh_20850.<locals>.statistic      ??1d3===r+   rA   /Array shapes are incompatible for broadcasting.r   N)r   r.   )r   r.   )Nr   Nr   )r  r   r-   N)r  r  )
r_   r`   r   r4   r   r   r  r1   r2   rU   )r5   r'   rQ   r&   rn   r   r6   s   &&     r(   test_gh_20850TestBootstrap.test_gh_20850  s    ii##J/JJszz'*+JJszz'*+	> 		*acc
IA6 D]]:W55OOQ&	NI6 6hK()4acc(m,ia@ 65s    EE	rr   N)rZ   r[   r\   r   r-   r.   ))rZ   gQ7@gHzS@)r[   g\(<@g=
ףpU@)r\   gHz'@@gQV@)r\   rZ   r[   )r   r  r-   )*r0   
__module____qualname____firstlineno__r   r7   rX   r1   markparametrizeri   r~   r   slowxfail_on_32bitr   tests_Rr   r   r   tests_against_itself_1sampitemsr   tests_against_itself_2sampr  r$  r.  r:  r?  rE  rK  rQ  rb  rm  r|  r  r  filterwarningsr  r  __static_attributes____classdictcell____classdict__s   @r(   r   r      s    g&<=F >F
99v [[X'EF[[VY/B 0 GB  [[X'EFB GB2 [[X'EF[[VY/[[Xe}5)D 6 0 G)DV [[[[ EF[[X'EFB G G B6&G [[8'BX CX,7$rA0 #*4"."'"/ [[[[/7==?A#A #J #*3"."5 [[[[/7==?A,A ,\ [[X'EF[[VaV,[[Wy)&<=Y > - GY8 [[ IJ[[X'EF[[VaV,N - G KN, [[X'EFH GH [[X'EFL GL"U  [[3aY?X @X8 [[ @A[[X'EF? G B?,3" [[!!"4)I " K[[Z-)GH+ IK+, [[Wk2[[VY/D 0 3D  [[VY/$ 0$4 [[[[X'EFB G B> [[[[ 89#B : #BL [[!!$F8!DA EAr+   r   c            
       F  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R.4      ]
P                  P                  R. R%O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      # )r^   r  )r4   )r  kwdsr  rsrvs_inr'   s   *,r(   r)   6TestMonteCarloHypothesisTest.get_rvs.<locals>.<lambda>  s(    RZZ0V20VQU0V6; &0 &=r+   rr   )r5   r  r  r  r'   s   &ffffr(   get_rvs$TestMonteCarloHypothesisTest.get_rvs  s    = 	=r+   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,          ,          # )rA   r  r  )r$   r  r|   )r&   rB   mvr}   r'   s   &&   r(   r   =TestMonteCarloHypothesisTest.get_statistic.<locals>.statistic  sB    %Aq2AA!cz>!r+   rr   )r5   r'   r   s   &f r(   get_statistic*TestMonteCarloHypothesisTest.get_statistic  s    	" r+   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      # r   r#   r(  s   &&r(   stat@TestMonteCarloHypothesisTest.test_input_validation.<locals>.stat	  s    7717((r+   r  r   c                     ^# r-   rr   r  s   &&&r(   r)   DTestMonteCarloHypothesisTest.test_input_validation.<locals>.<lambda>      1r+   rA   r?   r@   r;   r=   0`rvs` must be callable or sequence of callables.      @c                     V # r"   rr   r,  s   &r(   r)   r        ar+   If `rvs` is a sequence...c                     V # r"   rr   r,  s   &r(   r)   r  $  r  r+   c                     V # r"   rr   r,  s   &r(   r)   r  $  r  r+   z`statistic` must be callable.)`n_resamples` must be a positive integer.rE   rG   rH   rI   `alternative` must be in...r<   r   z!Signature inspection of statisticc                 b   < SP                  \        P                  P                  V R 7      4      # )rI  )r4   r   r   r   )r   r'   s   &r(   r   ?TestMonteCarloHypothesisTest.test_input_validation.<locals>.rvs@  s!    ::ejjnn$n788r+   r  r  r  r"   r.   rX  )r/   rX  rz   rT   )r4   zerosr   r   r   r1   r2   rU   r   r3   r$   str
startswith)r5   r'   r   r  r6   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      # r"   r#   r%   s   &r(   non_vectorized_statisticWTestMonteCarloHypothesisTest.test_input_validation_xp.<locals>.non_vectorized_statisticH  s    771:r+   z!`statistic` must be vectorized...Nr   Fr=   r  )
r4   r   r   r   r   r   r1   r2   rU   r$   )r5   r'   r  r6   rW   s   &f   r(   test_input_validation_xp5TestMonteCarloHypothesisTest.test_input_validation_xpG  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 rI  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  r|   rC  
batch_sizecounterr  )r&   rB   r  r5   r   r'   s   && r(   r   :TestMonteCarloHypothesisTest.test_batch.<locals>.statistic]  sX    ffkqwwqzJ#&z93G3G#HI "%%b)!77r+   rW   r   rF   r  r>   Ti rU  r   rJ   i  Nrr   )r_   r`   r   r4   standard_normalr  r  r  r   r   r   r   r   r   r   )	r5   r'   rQ   r&   r  rg   rh   res3r   s	   ff      @r(   
test_batch'TestMonteCarloHypothesisTest.test_batchV  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[[1r+   rB   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  64r  r  )r   r  r4  )popmeanrB   r  )r  r'   Ti N  )r>   rF   rB   r   N)r.   r/   rS   )r_   r`   r   r4   r  r  rg  r  r   ttest_1sampr  r  r   r   r   r   r   r   r   )r5   rB   r'   rQ   r   dtype_default	dtype_strdtype_npr  r&   r   r   r   rv   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?r+   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# ))rI  r4  r  rU  r   N)r_   r`   r   r  r   r  r4   r  r  r   r   r   r   r   r   r   )	r5   r   r'   rQ   r&   r>  r   r   rv   s	   &&&      r(   test_alternative-TestMonteCarloHypothesisTest.test_alternative  s     ii##H-R(2;?JJqM&&r*	ll5::>>3l6qyJrzz#--'@A

BJJszz$:Kr+   rt   r  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   rt   r   r^   r  c                 |   < \         P                  ! V \         P                  P                  R SR7      P                  # )asymp)moder   )r   ks_1sampr   cdfr   )r&   r   s   &r(   statistic1dGTestMonteCarloHypothesisTest.test_against_ks_1samp.<locals>.statistic1d  s+    >>!UZZ^^'.9;;D9Er+   r  FrF   r>   r   r   r   r   N)r_   r`   r   r   skewnormr   r(  r   r)  r  r   r   r   r   r   )	r5   r   rt   rQ   r&   r   r*  norm_rvsrv   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 #r+   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                   # r   )r   )r&   rB   r1  s   &&r(   r   LTestMonteCarloHypothesisTest.test_against_normality_tests.<locals>.statistic  s    A)333r+   Tr>   r   r   N)r_   r`   r   r   r-  r   r  r   r   r   r   r   r   )
r5   r1  r   rt   rQ   r&   r   r   r.  rv   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$))Dr+   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                  # r   )r   
normaltestr   )r&   rB   s   &&r(   r   GTestMonteCarloHypothesisTest.test_against_normaltest.<locals>.statistic  s    ##A1;;;r+   Tr   r5  r   N)r_   r`   r   r   r-  r   r:  r  r   r   r   r   r   r   )r5   rt   rQ   r&   r   r   r.  rv   s   &&      r(   test_against_normaltest4TestMonteCarloHypothesisTest.test_against_normaltest  s     ii##H-NN3?##A&	< <<

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

HOO$))Dr+   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                  # r"   )r   cramervonmisesr   r)  r   r,  s   &r(   r*  MTestMonteCarloHypothesisTest.test_against_cramervonmises.<locals>.statistic1d  s#    ''5::>>:DDDr+   r  Fr   r,  r   N)r_   r`   r   r   r-  r   r@  r   r)  r  r   r   r   r   r   )r5   rt   rQ   r&   r   r*  r.  rv   s   &&      r(   test_against_cramervonmises8TestMonteCarloHypothesisTest.test_against_cramervonmises  s     ii##I.NN#>''5::>>:	E <<

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

HOO$))Dr+   	dist_namer   logistictarget_statisticc                  aa VV3R  lp\         P                  ! 4       ;_uu_ 4        \         P                  ! R\        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RR7      pVP                  p	VP                  p
V3R lpV P!                  \#        \        S4      P                  V4      p\         P                  ! 4       ;_uu_ 4        \         P                  ! R\        4       \%        W|V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Ll; i  + '       g   i     Le; i)c                    < \         P                  P                  R 4      p\        P                  P                  V ^dVR7      p\        P                  ! VSRR7      pVP                  S,
          # )xr   interpolaterK   )r_   r`   r   r   tukeylambdar   andersonr   )rt   rQ   r&   r   rD  rF  s   &   r(   fun?TestMonteCarloHypothesisTest.test_against_anderson.<locals>.fun  sX    ))''	2C!!%%ac%DA~~a=IH%%(888r+   r2  )x0NrI  r   rJ  rK   c                 J   < \         P                  ! V SR R7      P                  # )rJ  rK   )r   rL  r   )r&   rD  s   &r(   r*  GTestMonteCarloHypothesisTest.test_against_anderson.<locals>.statistic1d!  s    >>!Y}EOOOr+   r  Fr   r,  r   )warningscatch_warningssimplefilterRuntimeWarningr   successr&   r_   r`   r   r   rK  r   rL  r   r   r  rg  r   r   r   )r5   rD  rF  rM  solrt   rQ   r&   r   expected_stat
expected_pr*  dist_rvsrv   s   &ff           r(   test_against_anderson2TestMonteCarloHypothesisTest.test_against_anderson  sL   	9
 $$&&!!(N;sq/C ' {{{{ EE!Hii##I.!!!#C!@>>!Y}E **__
	P <<y 9 = =sC$$&&!!(N;"1#.D.3LC ' 	}5

JQtyy[A5 '&&& '&s   )F3>,G3G	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   r5  g-C6?N)r_   r`   r   r  r   r$   r   )r5   rQ   r&   rv   s   &   r(   test_p_never_zero.TestMonteCarloHypothesisTest.test_p_never_zero.  sT     ii##$78HHSMq**bgg*.FDzzV###r+   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rI  c                 F    \         P                  ! WVR 7      P                  # r   r  r  s   &&&r(   r   FTestMonteCarloHypothesisTest.test_against_ttest_ind.<locals>.statistic<  r  r+   rA   {Gz?r   Nr  rz   )
r_   r`   r   r  r   r   r  r   r   r   r5   rQ   r   r   r   rv   r>  s   &      r(   test_against_ttest_ind3TestMonteCarloHypothesisTest.test_against_ttest_ind7  s    ii##$67zzvz&

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

CJJT:r+   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# )ra  rI  c                 B    \         P                  ! VR V / P                  # rA   )r   f_onewayr   )rB   r  s   $*r(   r   ETestMonteCarloHypothesisTest.test_against_f_oneway.<locals>.statisticK  s    >>43d3===r+   r   rB   r   rB   {Gz?r   Nr  )r.   e   )r.   f   )r.   g   rz   )
r_   r`   r   r  r   r   rj  r   r   r   re  s   &      r(   test_against_f_oneway2TestMonteCarloHypothesisTest.test_against_f_onewayD  s    ii##$67

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

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

CJJT:r+   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 r  c                 b   < R \         P                  ! RR7      P                  V SR7      ,          # )r  gZd;O?)rz  r   )r   	bernoullir   r   rQ   s   &r(   r   ITestMonteCarloHypothesisTest.test_finite_precision_statistic.<locals>.rvs]  s'    %044$S4QQQr+   r   )r   rF   Ng     ?)
r_   r`   r   r   r   r  r  null_distributionr   r   )r5   rF   r   r&   rv   c0c1rQ   s   &      @r(   test_finite_precision_statistic<TestMonteCarloHypothesisTest.test_finite_precision_statisticU  s     ii##$45	R H$$QRVV1<> VVC))S]]:;VVC))S]]G-DDExxzzb1f{Q7777r+   rr   )	two-sidedr   r   )r   r   g      ࿩r   r   r~  rZ  )333333?gffffff?g?)%r0   r  r  r  r   r_   r  r  r  r  r1   r  xslowr  r  r]  r  r!  r  linspacer/  r   skewtestkurtosistestr6  r{   r<  rB  r[  r^  rf  rq  	fail_slowr  r{  r  r  r  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$ [[[[[6:*>?[[/A%B B @ %BN$;;" [[1[[ TU8 V 8r+   r  c                   x  a  ] tR tRt o RR/R ltR t]P                  P                  R 4       t	]P                  P                  R 4       t
]P                  P                  R. ROR	7      R
 4       t]P                  P                  RRR7      ]P                  P                  R. ROR	7      R 4       4       tRtV tR# )	TestPowerij  r  Nc               :   aaa Sf   \        S4      MSoVVV3R l# )Nc                 J   < SP                  SP                  V R 7      SR7      # )rI  r  )r4   r  )r   r  rQ   r'   s   &r(   r)   %TestPower.xp_normal.<locals>.<lambda>n  s    BJJszztz'<EJJr+   )r   )r5   rQ   r'   r  s   &fddr(   	xp_normalTestPower.xp_normall  s    (- $5JJr+   c                   \         P                  P                  R 4      p\        P                  pV P                  W!R7      V P                  W!R7      3pVP                  ^
4      VP                  ^4      3pRp\        P                  ! \        VR7      ;_uu_ 4        \        W4V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        \        W0P                  W!R7      R3V4       RRR4       R	p\        P                  ! \        VR7      ;_uu_ 4        \        W0P                  W!R7      3V4       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W4R4       RRR4       R
p\        P                  ! \        VR7      ;_uu_ 4        \        W4WQP                  R4      R7       RRR4       VP                  R4      p\        V4      '       g=   Rp\        P                  ! \        VR7      ;_uu_ 4        \        W4WWR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W4VRR7       RRR4       Rp\        P                  ! \        \        3VR7      ;_uu_ 4        \        W4VP                  ^
^.4      VP                  . RO4      34       RRR4       \        P                  ! \        \        3VR7      ;_uu_ 4        \        W4VP                  ^
^.4      VP                  ^^.4      3RVP                  . RO4      /R7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        RWE4       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W4VRR7       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W4VRR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \        W4VRR7       RRR4       \        P                  ! \        VR7      ;_uu_ 4        \        W4V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Lv; i  + '       g   i     ELQ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELV; 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 rU  r;   r   r@   r=   Nr  r<   r  z/`significance` must be of floating point dtype.Tsignificancer  z8All elements of `significance` must be between 0. and 1.z`kwargs` must be a dictionary)kwargszNnot be broadcast|Chunks do not add|Incompatible shapes|Attempting to broadcastr&   z`test` must be callablez(`n_resamples` must be a positive integerrE   g      %@z"`batch` must be a positive integerrI   )r   r,   )r         i)r_   r`   r   r   r  r  r4   r1   r2   rU   r   r3   r   RuntimeError)r5   r'   rQ   testr   n_observationsr6   r  s   &&      r(   r  TestPower.test_input_validationp  s   ii##$78~~c~)4>>#>+EF**R."**R.9D]]:W55$^< 6 E]]9G44$n- 5]]9G44$3V<nM 5 .]]:W55$35~F 6]]:W55$U# 6 D]]:W55$^**T:JK 6 zz"~\**PGz99dK : 2]]9G44$^I> 5' 	 ]]J5WEE$bjj"b2BJJ|4LMN F]]J5WEE$bjj"b2BJJBx4HIrzz)457 F ,]]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5m 655 544444 655555 655 :99 544 FEEEEE
 544 655555 655555s   R/SS S+*S?%TT'T;1U4AU#(U7#VVV3W/S 	S	S(	+S<	?T	T$	'T8	;U	U 	#U4	7V	V	V0	3W	W	c           
       aa \         P                  P                  R 4      pVV3R lo^ Sn        ^ Sn        \        SSP                  ^
4      RR7      p\         P                  P                  R 4      p\        R/ VBRV P                  VSR7      R^/B pSP                  R8X  g   Q hSP                  ^8X  g   Q h\         P                  P                  R 4      p^ Sn        \        R/ VBRV P                  VSR7      R^2/B pSP                  ^8X  g   Q hSP                  ^28X  g   Q h\         P                  P                  R 4      p^ Sn        \        R/ VBRV P                  VSR7      RR/B pSP                  ^8X  g   Q hSP                  R8X  g   Q h\        VP                  VP                  4       \        VP                  VP                  4       R# )	r  c                   < V P                   ^8X  d   ^MV P                  ^ ,          p\        VSP                  4      Sn        S;P                  ^,          un        \
        P                  ! V SP                  R4      VR7      P                  # )r-   r4  rA   )	r  r|   rC  r  r  r   r  r4   r   )r&   rB   r  r  r'   s   && r(   r  "TestPower.test_batch.<locals>.test  s_    ffkqwwqzJ!*doo>DOLLAL$$Q

2TBIIIr+   r  )r  r  rF   r   rU  rJ   Nrr   )
r_   r`   r   r  r  r   r4   r   r  r   )r5   r'   rQ   r  rg   rh   r  r  s   &f     @r(   r  TestPower.test_batch  s    ii##K0	J
 #%::b> $& ii##K0EtE!;E1E||t###!###ii##K0FtF!;F2F||r!!!"$$$ii##K0HtH!;H4H||q   $&&&

DJJ/

DJJ/r+   c                  aaaa \         P                  P                  R 4      pRR^ R^R/oVP                  ^ R.4      oRVV3R llpVP                  . RO4      RVP                  3,          pRVP                  . RO4      /pVP                  . RO4      p\
        P                  ! W0P                  W!R	7      VWeR
7      p. pV F  p	\        VP                  ^ ,          4       F  p
WJR3,          pVR,           F}  o\        SP                  ^ ,          4       FZ  pSV,          oRVVV3R llp\
        P                  ! WP                  W!R	7      VV	R7      pVP                  VP                  4       K\  	  K  	  K  	  K  	  VP                  VP                  V4      VP                  P                  4      p\        VP                  VRRR7       R# )l   x7'\r   r~  r   皙?c           
         < \         P                  ! S\        \        ^V P                  ^,           4      4      R7      pS\        V4      ,          p\        P                  ! WVVR7      # )r-   rA   r   rB   )xpxexpand_dimsrV   r]  r  r   r   r  )r&   r   rB   popmeans_expandedalternativespopmeanss   &&& r(   r  *TestPower.test_vectorization.<locals>.test  sU     #5:5AFFQJ;O5P!R&s;'78K$$Q{*.0 0r+   rV  r   rm  rU  r  r  .c           	      X   < \         P                  ! V SVS\        S4      ,          R 7      # )rl  )r   r  r   )r&   rB   alternative_ir  	popmean_js   &&r(   test2+TestPower.test_vectorization.<locals>.test2  s+    #(#4#4Q	,8]9K,L$N Nr+   r  rd  )r   r   Nrz   ry   )r   r   rw  r   r   )rz   r   r-   )rm  r  皙?r   )r_   r`   r   r4   r  r   r   r  r]  r|   appendr   r   r   )r5   r'   rQ   r  nxr  r  rv   r>  significance_irs   nx_ijr  tmpr  r  r  r  s   &&             @@@@r(   test_vectorizationTestPower.test_vectorization  s    ii##N3FAk1i@ ::q#h'	0 	0 ZZ-.q"**}=J!78 zz":;kk$s :B'3D *N288A;'S&z%+M%:%:M"8>>!#45$,QK	N N $kk%1KT7EG

399- 6 &; ( + jj#		8 			3T=r+   Tcpu_onlyr  c           	     0   \         P                  P                  R 4      p\        P                  pVP                  VP                  ^
^d^
R7      4      VP                  VP                  ^
^d^
R7      4      3pV P                  W!R7      V P                  W!R7      3pVP                  . RO4      p\        P                  ! W5WFR7      pVP                  VRVP                  3,          VP                  P                  4      p\        VP                  VRR7       R# )	   &( rI  rU  rm  r  rV  r   N)rm  r  r   )r_   r`   r   r   r  r4   integersr  r   r   r  r|   r   )r5   r'   rQ   r  r  r   r  rv   s   &&      r(   test_ttest_ind_nullTestPower.test_ttest_ind_null  s    
 ii##O4**S\\"c\%EF**S\\"c\%EFHnnSn($...*DDzz"34kk$^O|ArzzM'BCIIOOT		<d;r+   rd  z+currently combines integer and float arraysr   c                   \         P                  P                  R 4      p. RO. R	O.. R
O. RO..pRVP                  . RO4      /pVP                  ^
.^..4      pVP                  RR.4      p\        P
                  ! \        P                  V P                  W!R7      VWdR7      p\        VP
                  VP                  V4      RR7       R# )r  r  rm  r  rU  r  r   N)gv?g]NbJ?g6;?)gOt]?g7gLڷ?g0Dҗ?)gVL[?g;c?g.H&?)g#*3)?glk?g5i ?)r   r  r   )	r_   r`   r   r4   r   r   r  r  r   )r5   r'   rQ   r>  r  r  r  rv   s   &&      r(   test_ttest_1samp_power TestPower.test_ttest_1samp_power  s     ii##O4 5464467
 RZZ89bTB4L1zz4,/kk%++T^^C^-G'3D		2::c?>r+   rr   )r  	jax.numpyz
dask.array)r0   r  r  r  r  r  r1   r  r  r  r  r   r  r  r  r  r  s   @r(   r  r  j  s     K$ K@9D [[#0 #0J [[*> *>X [[!!4-P " R<R< [[!!"4)V " X[[!!4-P " R?RX?r+   r  c                   B
  a  ] tR tRt o RtR tR t]P                  P                  R]
P                  P                  ]
P                  P                  .4      ]P                  P                  R. RDO4      R	 4       4       t]P                  P                  R]
P                  P                  ]
P                  P                  .4      ]P                  P                  R
R]P                   ! ^4      ^,          3RER]P"                  ! ^^4      3.4      R 4       4       tR t]P                  P)                  4       R 4       t]P                  P-                  RRR.R7      R 4       t]P                  P-                  RR7      ]P                  P                  RRF4      R 4       4       t]P                  P-                  RR7      ]P                  P                  RRF4      R 4       4       t]! RRR7      ]! RR7      ]P                  P                  RRF4      R 4       4       4       t]! RRR7      ]! RR7      ]! RR7      R 4       4       4       t]! RR7      ]P                  P                  RRG4      R 4       4       t]P                  P-                  RR7      ]P                  P                  RRF4      R 4       4       t]P                  P                  RRF4      R  4       t]P                  P-                  RR7      R! 4       t]P                  P                  RRF4      R" 4       t ]P                  PC                  4       ]P                  P                  RRH4      R# 4       4       t"R$. RIOR%. RJOR&R'R(R)R*R+R,R-R.R/R0R1/t#R$. RKOR%. RLOR&R2R(R3R*R4R,R5R.R6R0R7/t$]P                  P-                  RR7      ]P                  PC                  4       ]P                  P                  R8]#]$34      R9 4       4       4       t%]P                  P(                  ]P                  P                  R:RM4      ]P                  P-                  RRR.R7      ]P                  P-                  RR7      R; 4       4       4       4       t&]P                  P                  R<RN4      R= 4       t'](! ^ 4      ^. 3](! ^4      ^. ROO. RPO.3](! ^4      ^. ROO. RPO^^..3.t)]P                  P                  R>])4      R? 4       t*]P                  PW                  ^4      ]P                  P-                  RRR.R7      R@ 4       4       t,RA t-RBt.V t/RC# )QTestPermutationTesti/  r"  c                N    \         P                  P                  R 4      V n        R# )l   F N)r_   r`   r   rQ   )r5   s   &r(   setup_method TestPermutationTest.setup_method4  s    99(()<=r+   c                    R  pVP                  . RO4      VP                  . RO4      3pRp\        P                  ! \        VR7      ;_uu_ 4        \	        V^ ,          VP                  ^ .4      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        \	        W2RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2R	R
7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2RR7       RRR4       Rp\        P                  ! \        VR7      ;_uu_ 4        \	        W2R	R7       RRR4       Rp\        P                  ! \
        VR7      ;_uu_ 4        \	        W2RR7       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL|; i  + '       g   i     ELW; 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Lg; i  + '       g   i     EL?; i  + '       g   i     EL; i  + '       g   i     R# ; i)c                 F    \         P                  ! W3V4      P                  # r"   r  r  s   &&&r(   r  :TestPermutationTest.test_permutation_test_iv.<locals>.stat:  s    ??A640:::r+   z2each sample in `data` must contain two or more ...r   Nz6`data` must be a tuple containing at least two samplesr?   r@   rA   z `permutation_type` must be in...r<   permutation_typer;   r=   r  rE   rG   rH   rI   r  r  rN   rO   rP   r,   r  rT   )r4   r1   r2   rU   r   r3   )r5   r'   r  r   r6   s   &&   r(   test_permutation_test_iv,TestPermutationTest.test_permutation_test_iv8  s   	; 

9%rzz)'<=F]]:W55d1grzz1#7> 6 K]]:W55T4( 6]]9G44Q% 5 /]]:W55Tc2 6 5]]:W55T.46 6 E]]:W55TC8 6 >]]:W55TU; 6 >]]:W55TV< 6 @]]:W55Tu5 6 @]]:W55Tv6 6 0]]:W55TV< 6 A]]9G44TY7 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$L8MM M4NNN0 O<O8O,L!	$L5	8M		M	 M1	4N	N	N-	0O	O	O)	,O=	r^   r  pairingsindependentc           	     >  aa
 SP                  V P                  P                  ^
4      4      pSP                  V P                  P                  ^
4      4      pV
V3R lo
^ S
n        ^ S
n        R^dRVRR/p\
        P                  ! WE3S
3R^RV! ^ 4      /VB pS
P                  ^e8X  g   Q hS
P                  ^8X  g   Q h^ S
n        \
        P                  ! WE3S
3R^2RV! ^ 4      /VB pS
P                  ^8X  g   Q hS
P                  ^28X  g   Q h^ S
n        \
        P                  ! WE3S
3R^dRV! ^ 4      /VB p	S
P                  ^8X  g   Q hS
P                  ^d8X  g   Q h\        VP                  V	P                  4       \        VP                  V	P                  4       R# )	r   c                 
  < V P                   ^8X  d   ^MV P                  ^ ,          p\        VSP                  4      Sn        S;P                  ^,          un        SP                  WR7      SP                  WR7      ,
          # r+  )r  r|   rC  r  r  r$   )r&   rn   rB   r  r   r'   s   &&& r(   r   1TestPermutationTest.test_batch.<locals>.statisticz  sc    ffkqwwqzJ#&z93G3G#HI "7717(27717+@@@r+   rF   r  r>   TrJ   r^   N)	r4   rQ   r`   r  r  r   r   r   r   )r5   r  r^   r'   r&   rn   r  rg   rh   r  r   s   &&&f      @r(   r  TestPermutationTest.test_batchp  s    JJtxxr*+JJtxxr*+	A
 	 	s$68Hd$%%qfi Lq L3??LFJL  C'''##q(((	%%qfi Lr L3??LFJL  A%%%##r)))	%%qfi Ls L3??LFJL  A%%%##s***T[[1T[[1r+   zpermutation_type, exact_sizec           	       a SP                  V P                  P                  ^4      4      pSP                  V P                  P                  ^4      4      pV3R lpRVRR/p\        P                  ! WV3V3R^RV! ^ 4      /VB p	\        V	P                  4      ^8X  g   Q h\        P                  ! WV3V3/ VB p	\        V	P                  4      V8X  g   Q hR# )r/   c                 V   < SP                  WR 7      SP                  WR 7      ,
          # r   r#   rm   s   &&&r(   r   8TestPermutationTest.test_permutations.<locals>.statistic  r   r+   r  r>   TrF   r^   N)r4   rQ   r`   r   r   r	   rx  )
r5   r  
exact_sizer^   r'   r&   rn   r   r  rv   s
   &&&&f     r(   test_permutations%TestPermutationTest.test_permutations  s     JJtxxq)*JJtxxq)*	A #$4d$$$aVY KA K2>q/KEIKs,,-222$$aVY?$?s,,-;;;r+   c           
       a R ^ r2^^	Rrep\         P                  ! WE,           V4      V8  g   Q h\        P                  P	                  R4      pSP                  VP                  VR7      4      pSP                  VP                  VR7      4      pWx3p	V3R lp
RRRRR	^dR
VRV/p\        W3RV/VB p\        W3RSP                  /VB pVP                  VP                  8X  g   Q h\        VP                  VP                  RR7       R# )r   i]     U rI  c                 V   < SP                  WR 7      SP                  WR 7      ,
          # r   r#   rm   s   &&&r(   r   NTestPermutationTest.test_randomized_test_against_exact_both.<locals>.statistic  r   r+   r>   Tr  r  rJ   r   rQ   rF   rm  r   N)r   binomr_   r`   r   r4   r  r   infr   r   r   r5   r'   r   rQ   r  nypermutationsr&   rn   r   r   r  rv   rh   s   &f            r(   'test_randomized_test_against_exact_both;TestPermutationTest.test_randomized_test_against_exact_both  s    "1S !U}}RWb)L888ii##J/JJs***34JJs***34t	A d$6m[%FtQLQDQLRVVLtL}}...

DKKd;r+   c           
       a R Rr2^^Rrep^V,          V8  g   Q h\         P                  P                  R4      pSP                  VP	                  VR7      4      pSP                  VP	                  VR7      4      pWx3p	V3R lp
RRRR	R
^dRVRV/p\        W3RV/VB p\        W3RSP                  /VB pVP                  VP                  8X  g   Q h\        VP                  VP                  RR7       R# )r   Ni }  r  rI  c                 6   < SP                  W,
          VR 7      # r   r#   rm   s   &&&r(   r   QTestPermutationTest.test_randomized_test_against_exact_samples.<locals>.statistic  s    7715t7,,r+   r>   Tr  samplesrJ   r   rQ   rF   rm  r   )
r_   r`   r   r4   r  r   r  r   r   r   r  s   &f            r(   *test_randomized_test_against_exact_samples>TestPermutationTest.test_randomized_test_against_exact_samples  s    
 %dS!2u"u|###ii##J/JJs***34JJs***34t	- d$6	m[%FtQLQDQLRVVLtL}}...

DKKd;r+   Tr  r  r  c           
       a R V P                   r2^^Rrep\        P                  ! V4      V8  g   Q h\        P                  P                  R4      pVP                  VP                  VR7      4      pVP                  VP                  VR7      4      oV.pV3R lp	RRRRR	^dR
VRV/p
\        W3RV/V
B p\        W3RVP                  /V
B pVP                  VP                  8X  g   Q h\        VP                  VP                  RR7       R# )r~  i@  r  rI  c                 J   < \         P                  ! V SVR 7      P                  # r   )r   pearsonrr   )r&   rB   rn   s   &&r(   r   RTestPermutationTest.test_randomized_test_against_exact_pairings.<locals>.statistic  s    >>!QT2<<<r+   r>   Tr  r  rJ   r   rQ   rF   rm  r   N)rQ   r   	factorialr_   r`   r   r4   r  r   r  r   r   r   )r5   r'   r   rQ   r  r  r  r&   r   r   r  rv   rh   rn   s   &&           @r(   +test_randomized_test_against_exact_pairings?TestPermutationTest.test_randomized_test_against_exact_pairings  s   
 'S !U  $|333ii##J/JJs***34JJs***34s	= d$6	m[%FtQLQDQLRVVLtL}}...

DKKd;r+   )
eager_onlyr   c                @  aa V P                   P                  ^^R7      pV P                   P                  ^^^R7      p\        P                  ! W4SRR7      pVV3R lpSP	                  V4      SP	                  V4      rC\        W43V\        P                  RV P                   R7      p\        VP                  SP	                  VP                  4      V P                  R7       \        VP                  SP	                  VP                  4      V P                  R7       R	# )
rS   r   r   )r   r   r   exact)r   r'  c                    < \        V 4      \        V4      r\        P                  ! WVR SR7      pSP                  VP                  4      pVP
                  ^ 8X  d
   VR,          # T# )r&  )rB   r'  r   rr   )r   r   ks_2sampr4   r   r  )r&   rn   rB   rv   r   r'   s   &&& r(   r   <TestPermutationTest.test_against_ks_2samp.<locals>.statistic  sT    $Q'):1)=q..DwKXC**S]]+C!hh!m3r744r+   r   rF   r   rQ   r   N)rQ   r  r   r  r4   r   r_   r  r   r   r   r   r5   r   r'   r&   rn   r   r   rv   s   &ff     r(   test_against_ks_2samp)TestPermutationTest.test_against_ks_2samp	  s     HHOO!O,HHOOO3>>!KgN	5 zz!}bjjm1vybff+4$((D 	rzz(2D2D'EDIIV

BJJx$?diiPr+   c                V  a V P                   P                  ^^R7      pV P                   P                  ^^R7      pRRRRRR/pWQ,          p\        P                  ! W4VR7      pV3R lpSP	                  V4      SP	                  V4      rC\        W43V\        P                  WP                   R7      p	\        V	P                  SP	                  VP                  4      V P                  R7       \        V	P                  SP	                  VP                  4      V P                  R7       R	# )
rS   r  r   r   r~  r  c                    < \        V 4      \        V4      r\        P                  ! WVR 7      pSP                  VP                  4      pVP
                  ^ 8X  d
   VR,          # T# rA   rr   r   r   ansarir4   r   r  r&   rn   rB   rv   r'   s   &&& r(   r   :TestPermutationTest.test_against_ansari.<locals>.statistic.  P    $Q'):1)=q,,q$/C**S]]+C!hh!m3r744r+   r  r   N)rQ   r  r   r  r4   r   r_   r  r   r   r   r   )
r5   r   r'   r&   rn   alternative_correspondencealternative_scipyr   r   rv   s
   &&f       r(   test_against_ansari'TestPermutationTest.test_against_ansari!  s     HHOO!O,HHOO!O, '-i&/&1;&@" 7C<<2CD	5 zz!}bjjm1vybff+6HHF 	rzz(2D2D'EDIIV

BJJx$?diiPr+   zneeds mannwhitneyur   c           
     j   \         P                  P                  R	^ V P                  R7      p\         P                  P                  R	RV P                  R7      p\         P                  ! W4^VR7      pR pVP                  V4      VP                  V4      rC\        W43VRVP                  V^V P                  R7      p\        VP                  VP                  VP                  4      V P                  R7       \        VP                  VP                  VP                  4      V P                  R7       R# )
r/   r   r   r^   r  rl  c                 H    \         P                  ! WVR R7      P                  # 
asymptotic)rB   rL   )r   mannwhitneyur   r  s   &&&r(   r   @TestPermutationTest.test_against_mannwhitneyu.<locals>.statisticE  s    %%alKUUUr+   T)r>   rF   r   rB   rQ   r   N)r/   rX  r.   )r   uniformr   rQ   r  r4   r   r  r   r   r   r   r  s   &&&     r(   test_against_mannwhitneyu-TestPermutationTest.test_against_mannwhitneyu<  s     MM9!$((KMM9$TXXN%%aL	V zz!}bjjm1vyT+-66{$%4885 	rzz(2D2D'EDIIV

BJJx$?diiPr+   zneeds cramervonmises_2samp)r  c                n   \         P                  P                  ^^V P                  R7      p\         P                  P                  ^^^V P                  R7      p\         P                  ! W#RR7      pR pVP                  V4      VP                  V4      r2\        W#3V\        P                  RV P                  R7      p\        VP                  VP                  VP                  4      V P                  R7       \        VP                  VP                  VP                  4      V P                  R7       R	# )
rS   )r   r   r^   )r   r   r   r^   r  rK   c                 L    \         P                  ! WVR R7      pVP                  # r	  )r   cramervonmises_2sampr   )r&   rn   rB   rv   s   &&& r(   r   7TestPermutationTest.test_against_cvm.<locals>.statisticY  s     ,,Q\RC== r+   r   r  r   N)r   r   r   rQ   r  r4   r   r_   r  r   r   r   r   )r5   r'   r&   rn   r   r   rv   s   &&     r(   test_against_cvm$TestPermutationTest.test_against_cvmP  s     JJNNNBJJNNqNI--a7C	!
 zz!}bjjm1vybff+4$((D 	rzz(2D2D'EDIIV

BJJx$?diiPr+   rB   c                "   \         P                  P                  R 4      pVP                  ^R7      pVP                  RR7      pVP                  RR7      pWEV3p\        P                  ! VRV/ pR p	RVRRRRRV/p
V Uu. uF  qP                  V4      NK  	  pp\        Wy3R	VP                  /V
B p\        Wy3R	R
/V
B p\        VP                  VP                  VP                  4      V P                  ^,          R7       \        VP                  VP                  V P                  ^,          R7       \        VP                  VP                  VP                  4      RR7       \        VP                  VP                  RR7       R# u upi )l   Y}y!dh rI  rB   c                 B    \         P                  ! VR V / P                  # rA   )r   kruskalr   r  s   $*r(   r   GTestPermutationTest.test_vectorized_nsamp_ptype_both.<locals>.statistic{  s    ==$2T2<<<r+   r   r   r  r  rQ   rF   r  r   gQ?r   r   N)r-   r/   r.   )r.   r-   rS   )r_   r`   r   r   r  r4   r   r  r   r   r   r   )r5   rB   r'   rQ   r&   rn   r   r   r   r   r  data_rv   rh   s   &&&           r(    test_vectorized_nsamp_ptype_both4TestPermutationTest.test_vectorized_nsamp_ptype_bothe  sH    ii##$78JJQJ JJIJ&JJIJ&ay==$2T2	= mY"M5#?/34te

5!t4tKBFFKdKJTJTJ 	rzz(2D2D'EDIIVWKXt~~DIIaKH

BJJx$?dK

DKKd; 5s   Fc           
     z  a \         P                  P                  R^ V P                  R7      p\         P                  P                  RRV P                  R7      p\         P                  ! W4V^R7      pV3R lpV3R lpSP                  V4      SP                  V4      rCR^RVRR	R
V P                  R\        P                  /p\        W4,
          3V3/ VB p	\        W43V3/ VB p
\        V	P                  V
P                  V P                  R7       VR8w  d<   \        V
P                  SP                  VP                  4      V P                  R7       \        V
P                  SP                  VP                  4      V P                  R7       \        V	P                  V
P                  V P                  R7       R# )r/   r  r  r  c                    < \        V 4      p \        P                  ! V R VR7      pSP                  VP                  4      pVP
                  ^ 8X  d
   VR,          # T# r   r  rr   r   r   wilcoxonr4   r   r  )r   rB   rv   r'   s   && r(   statistic_1samp_1dETestPermutationTest.test_against_wilcoxon.<locals>.statistic_1samp_1d  sL     "!$A..TBC**S]]+C!hh!m3r744r+   c                    < \        V 4      \        V4      r\        P                  ! WR VR7      pSP                  VP                  4      pVP
                  ^ 8X  d
   VR,          # T# r  r   r  s   &&& r(   statistic_2samp_1dETestPermutationTest.test_against_wilcoxon.<locals>.statistic_2samp_1d  sR    $Q'):1)=q..6EC**S]]+C!hh!m3r744r+   rB   r   r  r  rQ   rF   r   r~  N)r/   rY  r.   )r   r  r   rQ   r!  r4   r_   r  r   r   r   r   r   )r5   r   r'   r&   rn   r   r"  r%  r  rg   rh   s   &&f        r(   test_against_wilcoxon)TestPermutationTest.test_against_wilcoxon  sK    MM9!$((KMM9$TXXN>>!KaH	5	5 zz!}bjjm1=+7I9txx8(:CdC(:CdC 	TYYG+%DNNBJJx7I7I,J!%, 	RZZ%@tyyQT[[tyyAr+   c           
        V P                   P                  ^ ^^
R7      pRW3^ 8H  &   RR lpV! V4      ^
Rrvp\        P                  ! WVWqR7      p\        P                  ! VP                  W2P                  R7      3VRRVP                  V P                   VR7      p	\        V	P                  VP                  VP                  4      V P                  R	7       R
# )r   rI  c                 D    \        V 4      pVP                  V ^ 8  VR7      # )r   rA   )r
   r   )r&   rB   xp_s   && r(   r   =TestPermutationTest.test_against_binomtest.<locals>.statistic  s&    !!$C$$QU$66r+   r  r  r  Tr  )r>   r  rF   rQ   r   r   Nrz   r   )rQ   r  r   r   r   r4   r  r  r   r   r   )
r5   r   r'   r&   r   kr}   rz  r   rv   s
   &&&       r(   test_against_binomtest*TestPermutationTest.test_against_binomtest  s     HHa,q&	
	7 A,Ca??1D$$bjj**j&E%G046?RVV)-{L 	

BJJx$?diiPr+   c                &  aa V P                   P                  ^R7      pW P                   P                  ^R7      ,           o\        P                  ! VSRR7      pVV3R lpSP	                  V4      p\        V3VR\        P                  V P                   R7      p\        VP                  SP	                  VP                  4      V P                  R7       \        VP                  SP	                  VP                  4      V P                  R7       R# )	rY  rI  r  rK   c                    < \        V 4      p \        P                  ! V SR VR7      pSP                  VP                  4      pVP
                  ^ 8X  d
   VR,          # T# )r
  )rL   rB   rr   )r   r   
kendalltaur4   r   r  )r&   rB   rv   r'   rn   s   && r(   r   >TestPermutationTest.test_against_kendalltau.<locals>.statistic  sN    !!$A""1a4HC**S]]+C!hh!m3r744r+   r  )r  rF   rQ   r   N)rQ   r  r   r2  r4   r   r_   r  r   r   r   r   )r5   r'   r&   r   r   rv   rn   s   &f    @r(   test_against_kendalltau+TestPermutationTest.test_against_kendalltau  s    HHOOO#Q''##Aq9	5 JJqMtY+-66txxA 	rzz(2D2D'EDIIV

BJJx$?diiPr+   c           	     ~  aa	 \         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SP                  V4      SP                  S	4      upo	VV	3R lp\        V3VRSP                  VVR7      p\
        P                  ! WQR7      p\        VP                  SP                  VP                  VP                  R7      4       R# )	l   	(yM4 r  g      ?c                 D   < SP                  V ^8H  S^8H  ,          VR7      # r+  )r   r&   rB   r'   rn   s   &&r(   r   @TestPermutationTest.test_against_fisher_exact.<locals>.statistic  s&    ##Q!VQ$7d#CCr+   r  )r  rF   r   rQ   r  r  N)r_   r`   r   r#  r   r   contingencycrosstabr4   r   r  fisher_exactr   r   r  )
r5   r   r'   rQ   r&   tabr   rv   rh   rn   s
   &&f      @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zz!}bjjm1	D tY+-66{#&( !!#?

BJJt{{!''J$JKr+   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.   rI  rA   c                  H    \         P                  ! V R RR7      P                  # )Tr
  rankedrL   )r   page_trend_testr   r   s   *r(   r*  LTestPermutationTest.test_vectorized_nsamp_ptype_samples.<locals>.statistic1d	  s"    ((d0<>>GiHr+   c                  H    \         P                  ! V R RR7      P                  # )Tr  rB  )r   rD  r   rE  s   *r(   pvalue1dITestPermutationTest.test_vectorized_nsamp_ptype_samples.<locals>.pvalue1d  s"    ((d0799?@r+   rB   r>   Fr   r   r  r  rQ   rF   r   r   r   r   N)r.   rS   r/   )r-   rS   r/   )r.   rS   r-   )rQ   r`   r   rankdatar   r  r_   broadcast_arraysr   r  r   r   r   r   )r5   rB   r&   rn   r   r   r*  rH  r   r   expected_statisticexpected_pvaluer  rv   rh   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;r+   r&   rn   expected_lessr  expected_2sidedg?expected_Pr_gte_S_meang&_?rL  g      @expected_avggd~$I"@expected_stdglu?gd?gd?gYo5 ?g     @@@g{C@gDmFA@casec           	       a VR,          pVR,          pSP                  VR,          4      pSP                  VR,          4      pSP                  VR,          4      pSP                  VR,          4      pSP                  VR,          4      p	SP                  VR,          4      p
V3R	 lp\        S4      pSP                  W<R
7      SP                  WLR
7      rC\        P                  ! 4       ;_uu_ 4        \        P                  ! RR\
        4       \        W43V\        P                  RR7      p\        W43V\        P                  RR7      pRRR4       \        XP                  WPP                  R7       \        VP                  VRR7       \        XP                  VRR7       \        SP                  VP                  4      V	RR7       \        SP                  VP                  4      V
RR7       VP                  pSP                  VP                  4      pVP                  P                   ^ ,          pSP#                  SP%                  SP'                  VP                  V,
          4      SP'                  VV,
          4      8  4      VP(                  4      V,          p\        VV4       R#   + '       g   i     ELm; 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.

r&   rn   rL  rP  rQ  rR  rS  rT  c                    < \        V 4      \        V4      r\        P                  ! WVR 7      pSP                  VP                  4      pVP
                  ^ 8X  d
   VR,          # T# r  r  r  s   &&& r(   r   5TestPermutationTest.test_with_ties.<locals>.statisticY  r  r+   r  r2  z$Ties preclude use of exact statisticr   )rF   r   r~  Nr   g|=r   r!  )r4   r   rR  rS  r  UserWarningr   r_   r  r   r   r   r   r$   rx  r   r|   r#  r   r   r  )r5   rU  r'   r&   rn   rL  rP  rQ  rR  rS  rT  r   r  rv   rh   Sr$   r}   Pr_gte_S_means   &&f                r(   test_with_ties"TestPermutationTest.test_with_ties2  s%   : IIZZ-A(BC

4#89**T*;%<=!#D1I,J!Kzz$~"67zz$~"67	5 !$zz!z)2::a:+E1$$&&##@+O"A69"&&/57C#QFI2660;=D ' 	'9		J

M>_5A 6 67DQt5564P MMwws,,-!!''*		""2"2FF3((-."&&4.@#BCD77LNOP'=>) '&&s   5AJ22K	zalternative, expected_pvaluec                  aa SP                  . R	O4      pSP                  . R
O4      oRpSP                  \        P                  ! \        S4      4      4      oVV3R lp\	        V3VRSP
                  VR7      p\        VP                  SP                  V4      V P                  R7       \        VP                  SP                  V4      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                    < SP                  \        P                  ! \        V 4      VR 7      4      p \        P                  ! V SVR 7      P
                  # r   )r4   r   rJ  r   r  r   r8  s   &&r(   r   BTestPermutationTest.test_against_spearmanr_in_R.<locals>.statistic  s=     

5>>*;A*>TJKA>>!QT2<<<r+   r  )r  rF   r   r   gvIh%<=r   N)g@9?gY,?gOQ?g[iY@g|?g鈶BE)gQGn@gU?gz˱@?gmGA6@gB @g˭?)
r4   r   rJ  r   r   r  r   r   r   r   )	r5   r   rM  r'   r&   rL  r   rv   rn   s	   &&&f    @r(   test_against_spearmanr_in_R/TestPermutationTest.test_against_spearmanr_in_Rx  s    . JJ < =JJ ; </JJu~~&7&:;<	= tY+-66{L 	rzz2D'EDIIV

BJJ$?eLr+   rJ   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,   )r1   r2   rU   r   r   _batch_generator)r5   rJ   s   &&r(   test_batch_generator_iv+TestPermutationTest.test_batch_generator_iv  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 # r"   )r   r   rd  )r5   iterablerJ   r   gots   &&&& r(   test_batch_generator(TestPermutationTest.test_batch_generator  s#     ;//@Ar+   c                   VP                  . ROVP                  R7      pVP                  . ROVP                  R7      pR p\        P                  ! W#3VRR7      pVP                  VP
                  VP                  rp^\        VP                  WR,
          8  4      4      ,          VP                  ^ ,          ,          p	Yyu;8X  d	   R	8X  g   Q h Q hR# )
r  r  c                 @    \         P                  ! WVR 7      ^ ,          # r   )r   r  r  s   &&&r(   r   FTestPermutationTest.test_finite_precision_statistic.<locals>.statistic  s    >>!T2155r+   r  r  r"  N)r  r  r  r  )r  r  g      @g       @gUUUUUU?)
r4   r  r   r   r   r   rx  r   r   r|   )
r5   r'   r&   rn   r   rv   rr   null	correct_ps
   &&        r(   r{  3TestPermutationTest.test_finite_precision_statistic  s     JJ'rzzJ:JJ'rzzJ:	6 $$aVY6@B--S5J5J4b..t5y/@ABBTZZPQ]R	)c)))))r+   c                  a \         P                  P                  R 4      p\        S4      pSP	                  VP                  ^4      VR7      pSP	                  ^ ^ ^ SP
                  ^ .4      pSP	                  VP                  ^4      VR7      pV3R lpRRRVRR/p\        WF3V3/ VB p	SP                  WDV,           .4      V3p
\        W3/ VB pSP	                  SP
                  VR7      p\        VP                  ^ ,          V	P                  4       \        VP                  ^ ,          V	P                  4       \        VP                  ^,          V4       \        VP                  ^,          V4       R# )	l    G+ r  c                 V   < SP                  WR 7      SP                  WR 7      ,
          # r   r#   rm   s   &&&r(   r   9TestPermutationTest.test_nan_statistic.<locals>.statistic  r   r+   r  r  rQ   rB   Nrz   )r_   r`   r   r   r4   r8  r   r   r   r   r   )r5   r'   rQ   r  r&   x_nanrn   r   r  r>  r   rv   NaNs   &f           r(   test_nan_statistic&TestPermutationTest.test_nan_statistic  s1    ii##J/ $JJszz!}EJ2

Aq!RVVQ/0JJszz!}EJ2	A #M5#vrJvy9D9!Y(!,t7$7jjuj-a(#--8

1szz2a(#.

1s+r+   rP   N)r  r  r  )r  r  r  )rz   r.   )rZ  r-   rR   )r@   r.   g      @)o   k   r   c   ro  j   m   l   )	r{  r  r}  b   i   rp  n   r  h   ))r   g?)r   gOO?)r~  g<OO?)rz   r   r  )r/   rS   rX  )0r0   r  r  r  r   r  r  r1   r  r  r_   r`   ra   r   r  r   r  r  r  r  r  r  r   r  r  r  r  r  r  r'  r.  r4  r>  r  rN  
tie_case_1
tie_case_2r\  ra  re  r]  batch_generator_casesrj  r  r{  rx  r  r  r  s   @r(   r  r  /  s     D>48p [[^bii.C.C.0ii.C.C.E F[[/CE"2EF"2J [[^bii.C.C.0ii.C.C.E F[[;)7+<+<Q+?+BC/,gmmAq.ABDE<	EF<4<2 [[< <4 [[!!4V[<Q!R< S<6 [[!!T!2[[],LMQ N 3Q, [[!!T!2[[],LMQ N 3Q2 f%9:&[[],LMQ N ' ;Q" f%AB&t$Q % ' CQ$ &[[VW-"< . '"<L [[!!T!2[[],LM#B N 3#BJ [[],LMQ NQ. [[!!T!2Q 3Q* [[],LML NL$ [[[[VW-)< . )<Z |S-!<#S*L& (NGEJ >C!<#\*L& )^XGJ [[!!T!2[[[[Vj*%=>A? ?  3A?F [[[[;>?
 [[!!4V[<Q!R[[!!T!2!M 3 S? !MF [[Wg.A /A $Ah2.#AhIy+AB#AhIy1a&+IJL [[8244 [[1[[!!4V[<Q!R* S *., ,r+   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.   rS   rz   )r_   r  r   cumsumsetr   _all_partitions_concatenatedsplitaddrV   	frozensetprodr]  r   r   r  r  r   )r}   ncall_partitionsr  partition_concatenatedpartitioningrs   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: rI  c                 F   < \         P                  P                  V SR 7      # )r   )r   r   r   rv  s   &r(   r   &test_parameter_vectorized.<locals>.rvs  s    zz~~4c~::r+   r   r   rQ   rL   r[   r   r  r  r   rW   r   rF   c                    < V P                   ^8  g    \        P                  ! V S4      '       g   Q h\        P                  ! WR7      # r+  )r  r_   array_equalr$   )r&   rB   rW   s   &&r(   r   ,test_parameter_vectorized.<locals>.statistic  s3    vvzR^^Av6666wwq$$r+   r   r>   NTc                 T    V P                   ^8X  g   Q h\        P                  ! V 4      # r  )r  r_   r$   r,  s   &r(   r   r    s     vv{{wwqzr+   Frr   )r_   r`   r   rg  r   r   )	r  r   fun_optionscommon_optionsrM  optionsr   rQ   rW   s	   &      @@r(   test_parameter_vectorizedr    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9r+   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   rQ   N)r_   r`   r   r1   r2   rU   r   MonteCarloMethod)r5   r6   rQ   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	rr   N)r0   r  r  r  r  r  r  r  s   @r(   r  r    s     < <r+   r  )r   r   r   )0rR  r1   r   r_   numpy.testingr   r   scipy._lib._utilr   scipy._lib._array_apir   r   r   r	   r
   r   r   r   scipy._lib._array_api_no_0dr   r   scipy._externalr   r  scipyr   r   scipy.fft.tests.test_fftlogr   scipy.optimizer   scipy.statsr   r   r   r   scipy.stats._resamplingr   lazy_xp_modulesr   r  r  r  r  r  r  r  r  rr   r+   r(   <module>r     s      7 )? ? ? I 2   8  L L - - ' 9VA VA VAt #$r8 r8 %r8j 5A? A? A?H #$t
, t
, %t
,n0* NP:P:B< <r+   