
    M/Ph	              
          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                            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dS )$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dS )TestBandwidthCalculationc                     g d}t          j                    }g d}t          g d          D ]\  }}t          t          ||          ||<   t          ||           d S )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         o/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/nonparametric/tests/test_bandwidths.py!test_calculate_bandwidth_gaussianz:TestBandwidthCalculation.test_calculate_bandwidth_gaussian   s{    , , , !!)) H H HII 	9 	9FB*2r488GBKKW-----    c                 R    d}t          t                    }t          ||           d S )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      s2        . . .) ) ) ) )r$   r   c                       e Zd Zd ZdS )CheckNormalReferenceConstantc                 N    | j         }| j        }t          ||j        d           d S )Ng{Gz?)constantr   r   normal_reference_constant)r   constr   s      r"   (test_calculate_normal_reference_constantzECheckNormalReferenceConstant.test_calculate_normal_reference_constant4   s+    yt=tDDDDDr$   N)r'   r(   r)   r1   r*   r$   r"   r,   r,   2   s(        E E E E Er$   r,   c                   0    e Zd Z ej                    ZdZdS )TestEpanechnikovgQ@N)r'   r(   r)   r   Epanechnikovr   r.   r*   r$   r"   r3   r3   :   s#        7!!DHHHr$   r3   c                   0    e Zd Z ej                    ZdZdS )TestGaussiang(\?N)r'   r(   r)   r   r   r   r.   r*   r$   r"   r6   r6   @   #        7DHHHr$   r6   c                   0    e Zd Z ej                    ZdZdS )TestBiweightg=
ףp=@N)r'   r(   r)   r   Biweightr   r.   r*   r$   r"   r9   r9   F   r7   r$   r9   c                   0    e Zd Z ej                    ZdZdS )TestTriweightg333333	@N)r'   r(   r)   r   	Triweightr   r.   r*   r$   r"   r<   r<   L   s#        7DHHHr$   r<   c                       e Zd Zd ZdS )BandwidthZeroc                     t          j                    }dD ]K}t          j        t          d          5  t          | j        ||           d d d            n# 1 swxY w Y   Ld S )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    !!< 	4 	4B|%BD D D 4 4 "d3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4s   AA	A	N)r'   r(   r)   rF   r*   r$   r"   r?   r?   R   s#        4 4 4 4 4r$   r?   c                   .    e Zd Z ej        d          ZdS )TestAllBandwidthZerod      N)r'   r(   r)   nponesrE   r*   r$   r"   rH   rH   ]   s        			BBBr$   rH   c                   V    e Zd Zej                            d          Zdedddf<   dS )TestAnyBandwidthZerorI   )r   g      ?Nr   )r'   r(   r)   rL   randomnormalrE   r*   r$   r"   rO   rO   b   s7        			x		(	(BBqqq!tHHHr$   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 5 5 5 5 5 = = = = = = A A A A A A D D D D D D * ) ) ) ) )  	u   [#cEJ
+C$2B///0D0D0DEG G G) ) ) ) ) ) ) ).E E E E E E E E    3       /       /       0   4 4 4 4 4 4 4 4    =   
    =     r$   