
    'YHh	              
          d Z ddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ ddlmZ ddlZej                  j!                  d	        ed
dgdej"                  ej"                  g edd       edd      f      Z G d d      Z G d d      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d      Z G d  d!e      Z G d" d#e      Zy)$zH

Tests for bandwidth selection and calculation.

Author: Padarn Wilson
    N)stats)kernels)mixture_rvs)select_bandwidth)bw_normal_reference)assert_allclosei90  g      ?g      ?   g      ?)locscale   )sizedistkwargsc                       e Zd Zd Zd Zy)TestBandwidthCalculationc                     g d}t        j                         }g d}t        g d      D ]  \  }}t        t        ||      ||<    t        ||       y )N)gb]O?gm1?:W?)r   r   r   scott	silvermannormal_reference)r   Gaussian	enumerater   Xir   )selfbw_expectedkernbw_calciibws         h/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/nonparametric/tests/test_bandwidths.py!test_calculate_bandwidth_gaussianz:TestBandwidthCalculation.test_calculate_bandwidth_gaussian   sU    , ! HI 	9FB*2r48GBK	9 	W-    c                 >    d}t        t              }t        ||       y )Nr   )r   r   r   )r   r   r!   s      r"   )test_calculate_normal_reference_bandwidthzBTestBandwidthCalculation.test_calculate_normal_reference_bandwidth+   s    ) $K(r$   N)__name__
__module____qualname__r#   r&    r$   r"   r   r      s    .)r$   r   c                       e Zd Zd Zy)CheckNormalReferenceConstantc                 b    | j                   }| j                  }t        ||j                  d       y )Ng{Gz?)constantr   r   normal_reference_constant)r   constr   s      r"   (test_calculate_normal_reference_constantzECheckNormalReferenceConstant.test_calculate_normal_reference_constant4   s&    yyt==tDr$   N)r'   r(   r)   r1   r*   r$   r"   r,   r,   2   s    Er$   r,   c                   2    e Zd Z ej                         ZdZy)TestEpanechnikovgQ@N)r'   r(   r)   r   Epanechnikovr   r.   r*   r$   r"   r3   r3   :   s    7!DHr$   r3   c                   2    e Zd Z ej                         ZdZy)TestGaussiang(\?N)r'   r(   r)   r   r   r   r.   r*   r$   r"   r6   r6   @       7DHr$   r6   c                   2    e Zd Z ej                         ZdZy)TestBiweightg=
ףp=@N)r'   r(   r)   r   Biweightr   r.   r*   r$   r"   r9   r9   F   r7   r$   r9   c                   2    e Zd Z ej                         ZdZy)TestTriweightg333333	@N)r'   r(   r)   r   	Triweightr   r.   r*   r$   r"   r<   r<   L   s    7DHr$   r<   c                       e Zd Zd Zy)BandwidthZeroc                     t        j                         }dD ]=  }t        j                  t        d      5  t        | j                  ||       d d d        ? y # 1 sw Y   JxY w)Nr   zSelected KDE bandwidth is 0)match)r   r   pytestraisesRuntimeErrorr   xx)r   r   r!   s      r"   test_bandwidth_zeroz!BandwidthZero.test_bandwidth_zeroT   s[    !< 	4B|%BD 4 "d34 4	44 4s   AA!	N)r'   r(   r)   rF   r*   r$   r"   r?   r?   R   s    4r$   r?   c                   0    e Zd Z ej                  d      Zy)TestAllBandwidthZerod      N)r'   r(   r)   nponesrE   r*   r$   r"   rH   rH   ]   s    		Br$   rH   c                   V    e Zd Zej                  j                  d      Zdedddf<   y)TestAnyBandwidthZerorI   )r   g      ?Nr   )r'   r(   r)   rL   randomnormalrE   r*   r$   r"   rO   rO   b   s&    			x		(BBq!tHr$   rO   )__doc__numpyrL   scipyr   !statsmodels.sandbox.nonparametricr   %statsmodels.distributions.mixture_rvsr   $statsmodels.nonparametric.bandwidthsr   r   numpy.testingr   rB   rP   seednormdictr   r   r,   r3   r6   r9   r<   r?   rH   rO   r*   r$   r"   <module>r\      s      5 = A D *  		u #cEJJ

+C2B/0DEG) ).E E3 / / 0 4 4= 
= r$   