ó
áp7]c        
   @  s$  d  Z  d d l m Z d d l m Z m Z m Z d d l Z d d l	 m
 Z
 d d l m Z d d l m Z d „  Z dE d	 d
 d d „ Z d „  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z i  Z i e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d <d „  Z i d „  d 6d „  d 6d „  d 6e d <i e d 6e d  <d! e f d" „  ƒ  YZ d# d$ „ Z d% d& „ Z dF d' d# d d d( „ Z  dG d' d# d) „ Z! d* e f d+ „  ƒ  YZ" e# d, k r d d- l$ m% Z% e% j& j' d. d/ d' ƒZ' e( d0 ƒ e( e e' d1 ƒ ƒ e e' d1 ƒ Z) e( e) j* ƒ  ƒ d d d d d d d g Z+ x' e+ D] Z, e( e, e) j* e, d ƒ ƒ qKWe( d2 ƒ d d3 l- m. Z. e. e/ ƒ Z0 d' Z1 xk e d# ƒ D]] Z2 e j3 j4 e1 ƒ Z' e e' d1 ƒ Z) x3 e+ D]+ Z, e0 e, j5 e) j* e, d ƒ d% d4 ƒ qÕWq§We j6 g  e+ D] Z, e0 e, ^ qƒ Z7 e( d5 d6 j8 e+ ƒ ƒ e( d7 e7 d8 k  j9 d4 ƒ ƒ e( d9 e7 d: k  j9 d4 ƒ ƒ e( d; e7 d< k  j9 d4 ƒ ƒ e d= „  d1 d> d' ƒd' Z1 d# Z: e  e" ƒ  d? dH d> e1 d@ e: dA d ƒZ; e j< e: e j6 dB dC dD g ƒ ƒ j= e> ƒ Z? e( e; e? ƒ n  d S(I   st  More Goodness of fit tests

contains

GOF : 1 sample gof tests based on Stephens 1970, plus AD A^2
bootstrap : vectorized bootstrap p-values for gof test with fitted parameters


Created : 2011-05-21
Author : Josef Perktold

parts based on ks_2samp and kstest from scipy.stats
(license: Scipy BSD, but were completely rewritten by Josef Perktold)


References
----------

iÿÿÿÿ(   t   print_function(   t   ranget   lmapt   string_typesN(   t   distributions(   t   cache_readonly(   t
   kolmogorovc   
      C  s:  t  t j |  | f ƒ \ }  } |  j d } | j d } t |  ƒ } t | ƒ } t j |  ƒ }  t j | ƒ } t j |  | g ƒ } t j |  | d d ƒd | } t j | | d d ƒd | } t j t j	 | | ƒ ƒ } t j
 | | t | | ƒ ƒ } y  t | d d | | ƒ }	 Wn d }	 n X| |	 f S(   sB  
    Computes the Kolmogorov-Smirnof statistic on 2 samples.

    This is a two-sided test for the null hypothesis that 2 independent samples
    are drawn from the same continuous distribution.

    Parameters
    ----------
    a, b : sequence of 1-D ndarrays
        two arrays of sample observations assumed to be drawn from a continuous
        distribution, sample sizes can be different


    Returns
    -------
    D : float
        KS statistic
    p-value : float
        two-tailed p-value


    Notes
    -----

    This tests whether 2 samples are drawn from the same distribution. Note
    that, like in the case of the one-sample K-S test, the distribution is
    assumed to be continuous.

    This is the two-sided test, one-sided tests are not implemented.
    The test uses the two-sided asymptotic Kolmogorov-Smirnov distribution.

    If the K-S statistic is small or the p-value is high, then we cannot
    reject the hypothesis that the distributions of the two samples
    are the same.

    Examples
    --------

    >>> from scipy import stats
    >>> import numpy as np
    >>> from scipy.stats import ks_2samp

    >>> #fix random seed to get the same result
    >>> np.random.seed(12345678)

    >>> n1 = 200  # size of first sample
    >>> n2 = 300  # size of second sample

    different distribution
    we can reject the null hypothesis since the pvalue is below 1%

    >>> rvs1 = stats.norm.rvs(size=n1,loc=0.,scale=1)
    >>> rvs2 = stats.norm.rvs(size=n2,loc=0.5,scale=1.5)
    >>> ks_2samp(rvs1,rvs2)
    (0.20833333333333337, 4.6674975515806989e-005)

    slightly different distribution
    we cannot reject the null hypothesis at a 10% or lower alpha since
    the pvalue at 0.144 is higher than 10%

    >>> rvs3 = stats.norm.rvs(size=n2,loc=0.01,scale=1.0)
    >>> ks_2samp(rvs1,rvs3)
    (0.10333333333333333, 0.14498781825751686)

    identical distribution
    we cannot reject the null hypothesis since the pvalue is high, 41%

    >>> rvs4 = stats.norm.rvs(size=n2,loc=0.0,scale=1.0)
    >>> ks_2samp(rvs1,rvs4)
    (0.07999999999999996, 0.41126949729859719)

    i    t   sidet   rightg      ð?g¸…ëQ¸¾?g)\Âõ(¼?(   R   t   npt   asarrayt   shapet   lent   sortt   concatenatet   searchsortedt   maxt   absolutet   sqrtt   floatt   ksprob(
   t   data1t   data2t   n1t   n2t   data_allt   cdf1t   cdf2t   dt   ent   prob(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   ks_2samp   s"    I  ! 
i   t	   two_sidedt   approxc         K  so  t  |  t ƒ rX | s" | |  k rI t t |  ƒ j } t t |  ƒ j }  qX t d ƒ ‚ n  t  | t ƒ r| t t | ƒ j } n  t |  ƒ r° i | d 6} t j	 |  | | Ž  ƒ } n t j	 |  ƒ } t
 | ƒ } | | | Œ } | d k r2t j d | d ƒ | | j ƒ  }	 | d k r2|	 t j j |	 | ƒ f Sn  | d k r†| t j d | ƒ | j ƒ  }
 | d k r†|
 t j j |
 | ƒ f Sn  | d k rkt j |	 |
 g ƒ } | d	 k rÖ| t j j | t j | ƒ ƒ f S| d
 k rkt j j | t j | ƒ ƒ } | d k s%| d | d d k rH| t j j | t j | ƒ ƒ f S| t j j | | ƒ d f Sqkn  d S(   sÏ  
    Perform the Kolmogorov-Smirnov test for goodness of fit

    This performs a test of the distribution G(x) of an observed
    random variable against a given distribution F(x). Under the null
    hypothesis the two distributions are identical, G(x)=F(x). The
    alternative hypothesis can be either 'two_sided' (default), 'less'
    or 'greater'. The KS test is only valid for continuous distributions.

    Parameters
    ----------
    rvs : string or array or callable
        string: name of a distribution in scipy.stats

        array: 1-D observations of random variables

        callable: function to generate random variables, requires keyword
        argument `size`

    cdf : string or callable
        string: name of a distribution in scipy.stats, if rvs is a string then
        cdf can evaluate to `False` or be the same as rvs
        callable: function to evaluate cdf

    args : tuple, sequence
        distribution parameters, used if rvs or cdf are strings
    N : int
        sample size if rvs is string or callable
    alternative : 'two_sided' (default), 'less' or 'greater'
        defines the alternative hypothesis (see explanation)

    mode : 'approx' (default) or 'asymp'
        defines the distribution used for calculating p-value

        'approx' : use approximation to exact distribution of test statistic

        'asymp' : use asymptotic distribution of test statistic


    Returns
    -------
    D : float
        KS test statistic, either D, D+ or D-
    p-value :  float
        one-tailed or two-tailed p-value

    Notes
    -----

    In the one-sided test, the alternative is that the empirical
    cumulative distribution function of the random variable is "less"
    or "greater" than the cumulative distribution function F(x) of the
    hypothesis, G(x)<=F(x), resp. G(x)>=F(x).

    Examples
    --------

    >>> from scipy import stats
    >>> import numpy as np
    >>> from scipy.stats import kstest

    >>> x = np.linspace(-15,15,9)
    >>> kstest(x,'norm')
    (0.44435602715924361, 0.038850142705171065)

    >>> np.random.seed(987654321) # set random seed to get the same result
    >>> kstest('norm','',N=100)
    (0.058352892479417884, 0.88531190944151261)

    is equivalent to this

    >>> np.random.seed(987654321)
    >>> kstest(stats.norm.rvs(size=100),'norm')
    (0.058352892479417884, 0.88531190944151261)

    Test against one-sided alternative hypothesis:

    >>> np.random.seed(987654321)

    Shift distribution to larger values, so that cdf_dgp(x)< norm.cdf(x):

    >>> x = stats.norm.rvs(loc=0.2, size=100)
    >>> kstest(x,'norm', alternative = 'less')
    (0.12464329735846891, 0.040989164077641749)

    Reject equal distribution against alternative hypothesis: less

    >>> kstest(x,'norm', alternative = 'greater')
    (0.0072115233216311081, 0.98531158590396395)

    Don't reject equal distribution against alternative hypothesis: greater

    >>> kstest(x,'norm', mode='asymp')
    (0.12464329735846891, 0.08944488871182088)


    Testing t distributed random variables against normal distribution:

    With 100 degrees of freedom the t distribution looks close to the normal
    distribution, and the kstest does not reject the hypothesis that the sample
    came from the normal distribution

    >>> np.random.seed(987654321)
    >>> stats.kstest(stats.t.rvs(100,size=100),'norm')
    (0.072018929165471257, 0.67630062862479168)

    With 3 degrees of freedom the t distribution looks sufficiently different
    from the normal distribution, that we can reject the hypothesis that the
    sample came from the normal distribution at a alpha=10% level

    >>> np.random.seed(987654321)
    >>> stats.kstest(stats.t.rvs(3,size=100),'norm')
    (0.131016895759829, 0.058826222555312224)

    s5   if rvs is string, cdf has to be the same distributiont   sizeR    t   greaterg      ð?i   t   lessg        t   asympR!   ij
  gš™™™™™é?g333333Ó?g     @@i   N(   R    R#   (   R    R$   (   t
   isinstanceR   t   getattrR   t   cdft   rvst   AttributeErrort   callableR	   R   R   t   arangeR   t   ksonet   sft	   kstwobignR   (   R)   R(   t   argst   Nt   alternativet   modet   kwdst   valst   cdfvalst   Dplust   Dmint   Dt   pval_two(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   kstest   s<    t$ #$#c         C  sy   t  j | ƒ d d t  j | ƒ } |  | } t  j d | d ƒ } t  j |  t  j d d d g ƒ k ƒ } | | | f S(   Ng¸…ëQ¸¾?g)\Âõ(¼?iþÿÿÿi   g=
×£p=ê?g      ð?(   R	   R   t   expt   sumt   array(   t   statt   nobst
   mod_factort   stat_modifiedt   pvalt   digits(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   dplus_st70_upp  s
    $
'c         C  s}   t  j | ƒ d d t  j | ƒ } |  | } d t  j d | d ƒ } t  j |  t  j d d d g ƒ k ƒ } | | | f S(   Ng¸…ëQ¸¾?g)\Âõ(¼?i   iþÿÿÿg…ëQ¸í?gHáz®Gñ?(   R	   R   R<   R=   R>   (   R?   R@   RA   RB   RC   RD   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt
   d_st70_upp)  s
    $
'c         C  s‹   t  j | ƒ d d t  j | ƒ } |  | } | d } d | d t  j d | ƒ } t  j |  t  j d d d g ƒ k ƒ } | | | f S(   Ng×£p=
×Ã?g¸…ëQ¸Î?i   i   iþÿÿÿgö(\Âõð?g)\Âõ(ô?(   R	   R   R<   R=   R>   (   R?   R@   RA   RB   t   zsquRC   RD   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt
   v_st70_upp1  s    $

'c         C  s]   d | } |  d | d | d d | } d t  j d d | ƒ } t  j } | | | f S(	   Ng      ð?gš™™™™™Ù?g333333ã?i   i   gš™™™™™©?gR¸…ëQ@i   (   R	   R<   t   nan(   R?   R@   t   nobsinvRB   RC   RD   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   wsqu_st70_upp:  s
    
"	c         C  sŒ   d | } |  d | d | d } | d d | 9} d t  j d | t  j d ƒ } t  j |  t  j d d d g ƒ k ƒ } | | | f S(	   Ng      ð?gš™™™™™¹?i   i   gš™™™™™é?iþÿÿÿgÂõ(\Ò?gÃõ(\ÂÕ?(   R	   R<   t   piR=   R>   (   R?   R@   RJ   RB   RC   RD   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   usqu_st70_uppB  s    
"'c         C  s   d | } |  d | d | d } | d d | 9} d t  j d | d	 t  j d ƒ } t  j |  t  j d
 d
 d g ƒ k ƒ } | | | f S(   Ng      ð?gffffffæ?gÍÌÌÌÌÌì?i   i   g®Gáz®ó?g‘í|?5^ô?iþÿÿÿg       @g)\Âõ(¼?g!°rh‘íÜ?(   R	   R<   RL   R=   R>   (   R?   R@   RJ   RB   RC   RD   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt
   a_st70_uppK  s    
&'t   d_plust   d_minusR   t   vt   wsqut   usqut   at   stephens70uppc         C  s“   t  j j |  t j | ƒ ƒ } | d k sC | d | d d k rl |  t  j j |  t j | ƒ ƒ t j f S|  t  j j |  | ƒ d t j f Sd  S(   Nij
  gš™™™™™é?g333333Ó?g     @@i   (   R   R/   R.   R	   R   RI   R-   (   R9   R1   R:   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   pval_kstest_approxa  s    $)c         C  s   |  t  j j |  | ƒ t j f S(   N(   R   R-   R.   R	   RI   (   R7   R1   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   <lambda>i  t    c         C  s   |  t  j j |  | ƒ t j f S(   N(   R   R-   R.   R	   RI   (   R8   R1   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRW   j  RX   c         C  s)   |  t  j j |  t j | ƒ ƒ t j f S(   N(   R   R/   R.   R	   R   RI   (   R9   R1   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRW   k  RX   t   scipyt   scipy_approxt   GOFc           B  s¤   e  Z d  Z d d d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d	 „  ƒ Z e d
 „  ƒ Z d d d „ Z RS(   sP  One Sample Goodness of Fit tests

    includes Kolmogorov-Smirnov D, D+, D-, Kuiper V, Cramer-von Mises W^2, U^2 and
    Anderson-Darling A, A^2. The p-values for all tests except for A^2 are based on
    the approximatiom given in Stephens 1970. A^2 has currently no p-values. For
    the Kolmogorov-Smirnov test the tests as given in scipy.stats are also available
    as options.




    design: I might want to retest with different distributions, to calculate
    data summary statistics only once, or add separate class that holds
    summary statistics and data (sounds good).




    i   c         C  sù   t  | t ƒ rX | s" | | k rI t t | ƒ j } t t | ƒ j } qX t d ƒ ‚ n  t  | t ƒ r| t t | ƒ j } n  t | ƒ r° i | d 6} t j	 | | | Ž  ƒ } n t j	 | ƒ } t
 | ƒ } | | | Œ } | |  _ | |  _ | |  _ d  S(   Ns5   if rvs is string, cdf has to be the same distributionR"   (   R&   R   R'   R   R(   R)   R*   R+   R	   R   R   R@   t   vals_sortedR6   (   t   selfR)   R(   R0   R1   R4   R5   R6   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   __init__‰  s     		c         C  s4   |  j  } |  j } t j d | d ƒ | | j ƒ  S(   Ng      ð?i   (   R@   R6   R	   R,   R   (   R]   R@   R6   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRO   £  s    		c         C  s0   |  j  } |  j } | t j d | ƒ | j ƒ  S(   Ng        (   R@   R6   R	   R,   R   (   R]   R@   R6   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRP   ©  s    		c         C  s   t  j |  j |  j g ƒ S(   N(   R	   R   RO   RP   (   R]   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyR   ¯  s    c         C  s   |  j  |  j S(   t   Kuiper(   RO   RP   (   R]   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRQ   ³  s    c         C  sV   |  j  } |  j } | d t j d | d ƒ d | d d j ƒ  d | d } | S(   s   Cramer von Misesg       @g      ð?i   i   g      (@(   R@   R6   R	   R,   R=   (   R]   R@   R6   RR   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRR   ¸  s
    		1c         C  s5   |  j  } |  j } |  j | | j ƒ  d d } | S(   Ng      à?i   (   R@   R6   RR   t   mean(   R]   R@   R6   RS   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRS   Â  s    		c         C  sŒ   |  j  } |  j } d } xW t d | ƒ D]F } | | | |  } | d k } d | | | | <| | j ƒ  7} q( W| d d | | } | S(   Ni    i   g      à?g      @g       @(   R@   R6   R   R=   (   R]   R@   R6   t   msumt   jt   mjt   maskRT   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRT   Ê  s    		c         C  sn   |  j  } |  j } d t j d | d ƒ d t j | ƒ t j d | d d d … ƒ j ƒ  | | } | S(   s3   Stephens 1974, doesn't have p-value formula for A^2g       @g      ð?i   Niÿÿÿÿ(   R@   R6   R	   R,   t   logR=   (   R]   R@   R6   t   asqu(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRf   Ú  s
    		=R   RU   c         C  sU   t  |  | ƒ } | d k r9 t | | | |  j ƒ | f St | | | |  j ƒ Sd S(   s
   

        RU   N(   R'   t	   gof_pvalsR@   (   R]   t   testidt   pvalsR?   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   get_testæ  s    (    (   t   __name__t
   __module__t   __doc__R^   R   RO   RP   R   RQ   RR   RS   RT   Rf   Rj   (    (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyR[   q  s   
id   c   
      C  s  d d l  m } | t ƒ } xe t d ƒ D]W } |  | ƒ } t | | ƒ } x3 t D]+ } | | j | j | d ƒ d d ƒ qQ Wq) Wt j	 g  t D] } | | ^ q‘ ƒ }	 t
 d d j t ƒ ƒ t
 d	 |	 d
 k  j d ƒ ƒ t
 d |	 d k  j d ƒ ƒ t
 d |	 d k  j d ƒ ƒ d  S(   Niÿÿÿÿ(   t   defaultdictiè  RU   i    i   s	            s         s   at 0.01:g{®Gáz„?s   at 0.05:gš™™™™™©?s   at 0.10:gš™™™™™¹?(   t   collectionsRn   t   listR   R[   t   all_gofst   appendRj   R	   R>   t   printt   joinR`   (
   t   randfnt   distrR@   Rn   t   resultst   iR)   t   goftt   tit   resarr(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   gof_mcø  s    -&i    c         C  sÈ   t  |  j ƒ } |  j | } t d ƒ g | } d g | } t d ƒ | | <t d d d ƒ | | <d t j d | d ƒ t | ƒ d t j |  ƒ t j d |  t | ƒ ƒ | j | ƒ | } | S(   s.   vectorized Anderson Darling A^2, Stephens 1974iÿÿÿÿg       @g      ð?i   N(	   R   R   t   slicet   NoneR	   R,   t   tupleRe   R=   (   R6   t   axist   ndimR@   t   slice_reverset   isliceRf   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   asquare	  s    [iÈ   c         C  s°  | d k	 r| d k r' t d ƒ ‚ n  t t j | t | ƒ ƒ ƒ } d } x£ t | ƒ D]• } |  j | i | | f d 6 }	 |  j |	 d d ƒ}
 t	 d „  |
 ƒ }
 t j
 |  j |	 |
 ƒ d d ƒ} t | d d ƒ} | | | k j ƒ  7} qY W| t | | ƒ S|  j | i | | f d 6 }	 |  j |	 d d ƒ}
 t	 d „  |
 ƒ }
 t j
 |  j |	 |
 ƒ d d ƒ} t | d d ƒ} | d k rœt j
 | ƒ } | S| | k j ƒ  Sd S(	   s  Monte Carlo (or parametric bootstrap) p-values for gof

    currently hardcoded for A^2 only

    assumes vectorized fit_vec method,
    builds and analyses (nobs, nrep) sample in one step

    rename function to less generic

    this works also with nrep=1

    s   using batching requires a valuei    R"   R€   i   c         S  s   t  j |  d ƒ S(   Ni   (   R	   t   expand_dims(   t   x(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRW   >  RX   c         S  s   t  j |  d ƒ S(   Ni   (   R	   R…   (   R†   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRW   G  RX   N(   R~   t
   ValueErrort   intR	   t   ceilR   R   R)   t   fit_vecR   R   R(   R„   R=   R`   (   Rv   R0   R@   t   nrept   valuet
   batch_sizet   n_batcht   countt   irepR)   t   paramsR6   R?   t   stat_sorted(    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt	   bootstrap   s,    !!c         C  sŽ   d } xy t  | ƒ D]k } | j | i | d 6 } | j | ƒ } t j | j | | ƒ ƒ }	 t |	 d d ƒ}
 | |
 |  k 7} q W| d | S(   sþ   Monte Carlo (or parametric bootstrap) p-values for gof

    currently hardcoded for A^2 only

    non vectorized, loops over all parametric bootstrap replications and calculates
    and returns specific p-value,

    rename function to less generic

    i    R"   R€   g      ð?(   R   R)   RŠ   R	   R   R(   R„   (   RŒ   Rv   R0   R@   R‹   R   R   R)   R‘   R6   R?   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt
   bootstrap2R  s    t   NewNormc           B  s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s-   just a holder for modified distributions
    i    c         C  s   | j  | ƒ | j | ƒ f S(   N(   R`   t   std(   R]   R†   R€   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRŠ   s  s    c         C  s$   t  j j | d | d d | d ƒS(   Nt   loci    t   scalei   (   R   t   normR(   (   R]   R†   R0   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyR(   v  s    c         C  s/   | d } | d } | | t  j j d | ƒ S(   Ni    i   R"   (   R   R™   R)   (   R]   R0   R"   R—   R˜   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyR)   y  s    

(   Rk   Rl   Rm   RŠ   R(   R)   (    (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyR•   o  s   	t   __main__(   t   statsi   R"   s   scipy kstestR™   s   
Is it correctly sized?(   Rn   i   s	            s         s   at 0.01:g{®Gáz„?s   at 0.05:gš™™™™™©?s   at 0.10:gš™™™™™¹?c         C  s   t  j j d d |  ƒS(   Ni   R"   (   R›   t   tR)   (   R@   (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyRW      RX   R@   R0   R‹   RŒ   g®Gáz®ï?gffffffî?gÍÌÌÌÌÌì?(    (    (    (   i    i   (@   Rm   t
   __future__R    t   statsmodels.compat.pythonR   R   R   t   numpyR	   t   scipy.statsR   t   statsmodels.tools.decoratorsR   t   scipy.specialR   R   R   R;   RE   t   dminus_st70_uppRF   RH   RK   RM   RN   Rg   RV   t   objectR[   R|   R„   R~   R“   R”   R•   Rk   RY   R›   Rœ   R)   Rs   Ry   Rj   Rq   Rz   Ro   Rn   Rp   Rw   R@   Rx   t   randomt   randnRr   R>   R{   Rt   R`   R‹   t   btt   floort   astypeRˆ   t
   quantindex(    (    (    sH   lib/python2.7/site-packages/statsmodels/sandbox/distributions/gof_new.pyt   <module>   sˆ   	`Ÿ									

‡2

-&'.