U
    Kvf	                  	   @   s&  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dedddfdZG dd dZG dd dZG dd deZG dd deZG dd deZG dd deZG dd dZG d d! d!eZG d"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      ?)locZscale   )sizedistkwargsc                   @   s   e Zd Zdd Zdd ZdS )TestBandwidthCalculationc                 C   sR   dddg}t  }dddg}tdddgD ]\}}tt||||< q*t|| d S )Ngb]O?gm1?:W?r   scott	silvermannormal_reference)r   Gaussian	enumerater   Xir   )selfbw_expectedkernZbw_calciibw r   S/tmp/pip-unpacked-wheel-2v6byqio/statsmodels/nonparametric/tests/test_bandwidths.py!test_calculate_bandwidth_gaussian   s    
z:TestBandwidthCalculation.test_calculate_bandwidth_gaussianc                 C   s   d}t t}t|| d S )Nr   )r   r   r   )r   r   r   r   r   r   )test_calculate_normal_reference_bandwidth,   s    zBTestBandwidthCalculation.test_calculate_normal_reference_bandwidthN)__name__
__module____qualname__r   r   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd ZdS )CheckNormalReferenceConstantc                 C   s   | j }| j}t||jd d S )Ng{Gz?)constantr   r   Znormal_reference_constant)r   constr   r   r   r   (test_calculate_normal_reference_constant5   s    zECheckNormalReferenceConstant.test_calculate_normal_reference_constantN)r    r!   r"   r&   r   r   r   r   r#   3   s   r#   c                   @   s   e Zd Ze ZdZdS )TestEpanechnikovgQ@N)r    r!   r"   r   ZEpanechnikovr   r$   r   r   r   r   r'   ;   s   r'   c                   @   s   e Zd Ze ZdZdS )TestGaussiang(\?N)r    r!   r"   r   r   r   r$   r   r   r   r   r(   A   s   r(   c                   @   s   e Zd Ze ZdZdS )TestBiweightg=
ףp=@N)r    r!   r"   r   ZBiweightr   r$   r   r   r   r   r)   G   s   r)   c                   @   s   e Zd Ze ZdZdS )TestTriweightg333333	@N)r    r!   r"   r   Z	Triweightr   r$   r   r   r   r   r*   M   s   r*   c                   @   s   e Zd Zdd ZdS )BandwidthZeroc              
   C   s>   t  }dD ],}tjtdd t| j|| W 5 Q R X qd S )N)r   r   r   zSelected KDE bandwidth is 0)match)r   r   pytestZraisesRuntimeErrorr   xx)r   r   r   r   r   r   test_bandwidth_zeroU   s    z!BandwidthZero.test_bandwidth_zeroN)r    r!   r"   r0   r   r   r   r   r+   S   s   r+   c                   @   s   e Zd ZedZdS )TestAllBandwidthZerod      N)r    r!   r"   npZonesr/   r   r   r   r   r1   ^   s   r1   c                   @   s*   e Zd ZejjddZdedddf< dS )TestAnyBandwidthZeror2   )r   g      ?Nr   )r    r!   r"   r5   randomnormalr/   r   r   r   r   r6   c   s   r6   )__doc__Znumpyr5   Zscipyr   Z!statsmodels.sandbox.nonparametricr   Z%statsmodels.distributions.mixture_rvsr   Z$statsmodels.nonparametric.bandwidthsr   r   Znumpy.testingr   r-   r7   seedZnormdictr   r   r#   r'   r(   r)   r*   r+   r1   r6   r   r   r   r   <module>   s*   