ó
áp7]c           @   s…   d  d l  Z d  d l Z d  d l m Z m Z m Z d  d l m	 Z	 d  d l
 m Z m Z d Z d d „ Z d d „ Z d	 „  Z d S(
   iÿÿÿÿN(   t   reciprt   recipr0t   clean0(   t   mad(   t   StepFunctiont   monotone_fn_invertert   restructuredtextgê-™—q=c         C   s’   t  j |  ƒ }  t |  j ƒ d k rn t j j |  ƒ } t t  j j	 t  j
 | | j ƒ  | ƒ j t  j ƒ ƒ ƒ St t  j t  j |  d ƒ ƒ ƒ Sd S(   sZ   
    Return the rank of a matrix X based on its generalized inverse,
    not the SVD.
    i   g        N(   t   npt   asarrayt   lent   shapet   scipyt   linalgt   svdvalst   intt   addt   reducet   greatert   maxt   astypet   int32t   alltruet   equal(   t   Xt   condt   D(    (    s<   lib/python2.7/site-packages/statsmodels/sandbox/utils_old.pyt   rank   s
    8c         C   s¾   | d k r t |  ƒ } n  t j j |  d d ƒ\ } } } t j | ƒ } | d d d … } g  } x5 t | ƒ D]' } | j | d d … | | f ƒ qq Wt j t j	 | ƒ ƒ j
 t j ƒ S(   s»   
    Return a matrix whose column span is the same as X.

    If the rank of X is known it can be specified as r -- no check
    is made to ensure that this really is the rank of X.

    t   full_matricesi    Niÿÿÿÿ(   t   NoneR   R   R   t   svdt   argsortt   ranget   appendR   t	   transposeR   t   float64(   R   t   rt   VR   t   Ut   ordert   valuet   i(    (    s<   lib/python2.7/site-packages/statsmodels/sandbox/utils_old.pyt   fullrank   s    	!%c         C   sk   t  j |  d t ƒ} | j ƒ  t  j | j d d ƒ| _ | j d } t  j | ƒ d | } t | | ƒ S(   s9   
    Return the ECDF of an array as a step function.
    t   copyt   axisi    g      ð?(   R   t   arrayt   Truet   sortt   productR
   t   arangeR   (   t   valuest   xt   nt   y(    (    s<   lib/python2.7/site-packages/statsmodels/sandbox/utils_old.pyt   ECDF.   s    
(   t   numpyR   t   scipy.linalgR   t   statsmodels.tools.toolsR    R   R   t   statsmodels.robust.scaleR   t0   statsmodels.distributions.empirical_distributionR   R   t   __docformat__R   R   R)   R5   (    (    (    s<   lib/python2.7/site-packages/statsmodels/sandbox/utils_old.pyt   <module>   s   