Ñò
pXJc        F   @   s¼  d  Z  d Z d Z d d d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH gF Z dI dJ k Z dI dK k l Z dI dJ k i Z dI dL k l	 Z	 l
 Z
 l Z dI dJ k Z dI dJ k Z dI dJ k Z dI dJ k i Z dI dJ k i Z dI dJ k Z dM Z dN „  Z dO „  Z dP „  Z dQ „  Z dR „  Z e dS „ Z dJ e dT „ Z dU dV „ Z e i i  e _  dU dW „ Z e i i  e _  dU dX „ Z  e i  i  e  _  dY „  Z! e i! i  e! _  dZ „  Z" e i# Z# e i$ Z$ d[ „  Z% e& d\ „ Z' e& e d] „ Z( d^ „  Z) d_ „  Z* e i* i  o e i* i  e e* _  n d` „  Z+ e i+ i  o e i+ i  e e+ _  n dJ da db „ Z, dc „  Z- dd „  Z. e i/ i  e. _  e. Z/ dU de „ Z0 e i0 i  e0 _  dJ df „ Z1 e i1 i  e1 _  dJ dg „ Z2 e i2 i  e2 _  e& dh „ Z3 di „  Z4 e4 Z5 e i5 i  e4 _  e i6 Z7 dj „  Z8 dk dl „ Z9 e9 Z: dm „  Z; dJ dJ dU dn „ Z< dJ e& e& f do „ Z= dJ e& e& f dJ dp „ Z> dq Z? dJ e& e& f e dJ dr „ Z@ e@ i  o e@ i  e? e@ _  n ds e& e& f dJ dt „ ZA ds du e& e& f dJ dv „ ZB eB ZC d¡ d¢ e& dJ dy „ ZD d£ d¤ e& dJ dU dz „ ZE d¥ d¦ e& dJ dU d{ „ ZF d§ d¨ dJ d| „ ZG dJ e& e& f d} „ ZH e iH i  eH _  dJ e& e& f d~ „ ZI e iI i  eI _  dJ dU e& d „ ZJ e iJ i  eJ _  dU e& d€ „ ZK e iK i  eK _  dJ e& e& f d „ ZL e iL i  eL _  dJ e& e& f e dJ d‚ „ ZM dx dU dƒ „ ZN e iN i  eN _  dU d„ „ ZO e iO i  eO _  dU e& d… „ ZP e iP i  eP _  dU e& e& d† „ ZQ e iQ i  eQ _  dU d‡ „ ZR dJ dˆ „ ZS dU d‰ „ ZT e iT i  eT _  dU dŠ „ ZU e iU i  eU _  dU d‹ „ ZV e iV i  eV _  eW dŒ d dŽ g ƒ d d dJ d© d „ ZX dª d d d‘ „ ZY d d d’ „ ZZ eZ Z[ d“ „  Z\ dU d” „ Z] dU d• „ Z^ dU d– „ Z_ dJ d— „ Z` e i` i  e` _  dJ d˜ „ Za e ia i  ea _  dU d™ „ Zb e ib i  eb _  dU dš „ Zc e ic i  ec _  d› „  Zd e id i  ed _  dœ „  Ze e ie i  ee _  dU d „ Zf e if i  ef _  dž „  Zg dŸ „  Zh d  „  Zi dJ S(«   s~   
An extension of scipy.stats.stats to support masked arrays

:author: Pierre GF Gerard-Marchant
:contact: pierregm_at_uga_edu
s   Pierre GF Gerard-Marchants   restructuredtext ent   argstoarrayt   betait   covt	   chisquaret   count_tied_groupst   describet   f_onewayt   f_value_wilks_lambdat   find_repeatst   friedmanchisquaret   gmeant   hmeant
   kendalltaut   kendalltau_seasonalt   kruskalt   kruskalwallist
   ks_twosampt   ks_2sampt   kurtosist   kurtosistestt
   linregresst   mannwhitneyut   meppft   modet   momentt
   mquantilest   msignt
   normaltestt   obrientransformt   pearsonrt   plotting_positionst   pointbiserialrt   rankdatat	   samplestdt	   samplevart   scoreatpercentilet   semt   stdt   sen_seasonal_slopest   signaltonoiset   skewt   skewtestt	   spearmanrt   stderrt   theilslopest	   thresholdt   tmaxt   tmeant   tmint   trimt   trimbotht   trimtailt   trimat   trimrt   trimmed_meant   trimmed_stdt   trimmed_stdet   trimmed_vart   tsemt   ttest_1sampt   ttest_onesampt	   ttest_indt	   ttest_relt   tvart   vart	   variationt	   winsorizet   zt   zmapt   zsiÿÿÿÿN(   t   ndarray(   t   MaskedArrayt   maskedt   nomasks‚   
Notes
-----
    Missing values are considered pair-wise: if a value is missing in x,
    the corresponding value in y is masked.
c         C   sE   | d  j o t i |  ƒ }  d } n t i |  ƒ }  | } |  | f S(   Ni    (   t   Nonet   mat   ravelt
   asanyarray(   t   at   axist   outaxis(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _chk_asarrayA   s    
c         C   sf   | d  j o( t i |  ƒ }  t i | ƒ } d } n% t i |  ƒ }  t i | ƒ } | } |  | | f S(   Ni    (   RJ   RK   RL   RM   (   RN   t   bRO   RP   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _chk2_asarrayJ   s    
c         C   se   t  i |  ƒ }  t  i | ƒ } |  i | i } } | | j o t d | | f ƒ ‚ n |  | | f S(   Ns4   The size of the input array should match! (%s <> %s)(   RK   RM   t   sizet
   ValueError(   RN   RR   t   nat   nb(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt	   _chk_sizeU   s    c       	   G   s  t  |  ƒ d j oL t |  d t ƒ o7 t i |  d ƒ } | i d j o t d ƒ ‚ qû n t  |  ƒ } t g  } |  D] } | t  | ƒ qy ~ ƒ } t i t	 i
 | | f d t ƒd t ƒ} x6 t |  ƒ D]( \ } } | | | d t  | ƒ … f <qÏ Wt | t	 i t	 i | i ƒ ƒ <| S(   sC  Constructs a 2D array from a sequence of sequences. Sequences are filled
    with missing values to match the length of the longest sequence.

    Returns
    -------
        output : MaskedArray
            a (mxn) masked array, where m is the number of arguments and n the
            length of the longest argument.
    i   i    i   s   The input should be 2Dt   dtypet   maskN(   t   lent
   isinstanceRF   RK   t   asarrayt   ndimRU   t   maxt   arrayt   npt   emptyt   floatt   Truet	   enumerateRH   t   logical_nott   isfinitet   _data(   t   argst   outputt   nt   _[1]t   kt   mt   v(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR    ^   s    
(-*  c         C   sx   t  i |  ƒ } | i p t i d ƒ t i d ƒ f St i t  i t  i |  ƒ d t ƒƒ \ } } } | |  | |  f S(   sD  Find repeats in arr and return a tuple (repeats, repeat_count).
    Masked values are discarded.

Parameters
----------
    arr : sequence
        Input array. The array is flattened if it is not 1D.

Returns
-------
    repeats : ndarray
        Array of repeated values.
    counts : ndarray
        Array of counts.

    i    t   copy(   RK   t
   compressedRT   Ra   R`   t   futilt   dfrepsRd   (   t   arrt   marrt   v1t   v2Rk   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   {   s
    
0c         C   sã   t  i |  ƒ i ƒ  } t  i |  ƒ i ƒ  } t | ƒ \ } } h  } t | ƒ oJ t t t	 i
 | ƒ t i d ƒ ƒ ƒ } | i t t t | ƒ Œ  ƒ ƒ n | o? | o8 y | | c d 7<Wqß t j
 o d | | <qß Xn | S(   sÀ  Counts the number of tied values in x, and returns a dictionary
    (nb of ties: nb of groups).

Parameters
----------
    x : sequence
        Sequence of data on which to counts the ties
    use_missing : boolean
        Whether to consider missing values as tied.

Example
-------
    >>>z = [0, 0, 0, 2, 2, 2, 3, 3, 4, 5, 6]
    >>>count_tied_groups(z)
    >>>{2:1, 3:2}
    >>># The ties were 0 (3x), 2 (3x) and 3 (2x)
    >>>z = ma.array([0, 0, 1, 2, 2, 2, 3, 3, 4, 5, 6])
    >>>count_tied_groups(z)
    >>>{2:2, 3:1}
    >>># The ties were 0 (2x), 2 (3x) and 3 (2x)
    >>>z[[1,-1]] = masked
    >>>count_tied_groups(z)
    >>>{2:2, 3:1}
    >>># The ties were 2 (3x), 3 (2x) and masked (2x)
    i   (   RK   t   getmaskt   sumRq   Rp   R   R[   t   dictt   zipRa   t   uniquet	   itertoolst   repeatt   updatet   KeyError(   t   xt   use_missingt   nmaskedt   datat   tiest   countst   nties(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   “   s    '#c         C   s’   t  d „ } t i |  d t  ƒ}  | d j oA |  i d j o  | |  i ƒ  | ƒ i |  i ƒ S| |  | ƒ Sn  t i | | |  | ƒ i	 t
 ƒ Sd S(   sP  Returns the rank (also known as order statistics) of each data point
    along the given axis.

    If some values are tied, their rank is averaged.
    If some values are masked, their rank is set to 0 if use_missing is False,
    or set to the average rank of the unmasked values if use_missing is True.

    Parameters
    ----------
        data : sequence
            Input data. The data is transformed to a masked array
        axis : {None,int} optional
            Axis along which to perform the ranking.
            If None, the array is first flattened. An exception is raised if
            the axis is specified for arrays with a dimension larger than 2
        use_missing : {boolean} optional
            Whether the masked values have a rank of 0 (False) or equal to the
            average rank of the unmasked values (True).
    c         S   sÑ   |  i  ƒ  } t i |  i d t ƒ} |  i ƒ  } t i d | d ƒ | | |  <| o | d d | | | <n d | | | <t |  i ƒ  ƒ } x; | d D]/ } |  | j i	 t
 ƒ } | | i ƒ  | | <qš W| S(   NRY   i   g       @i    (   t   countRa   Rb   RT   Rc   t   argsortt   arangeR   Rp   t   filledt   Falset   mean(   R„   R‚   Rk   t   rkt   idxt   repeatst   rt	   condition(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _rank1dÒ   s     Rp   i   N(   RŒ   RK   R`   RJ   R^   RL   t   reshapet   shapet   apply_along_axist   viewRF   (   R„   RO   R‚   R“   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR    ½   s     i    c         C   s=   t  |  | ƒ \ }  } t i |  ƒ } t i | i d | ƒ ƒ S(   NRO   (   RQ   RK   t   logt   expR   (   RN   RO   t   log_a(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR
   ñ   s    c         C   sZ   t  |  | ƒ \ }  } t |  t ƒ o |  i | ƒ } n |  i | } | d |  i | ƒ S(   Ng      ð?(   RQ   R\   RG   Rˆ   R•   Ry   (   RN   RO   RT   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   ø   s
    c         C   sï   d „  } | d  j o? | t i |  ƒ ƒ } t i | d ƒ t i | d ƒ f } n— t i | | |  ƒ } t |  i ƒ } d | | <t d  ƒ g | i } d | | <| t	 | ƒ i
 | ƒ } d | | <| t	 | ƒ i
 | ƒ } | | f } | S(   Nc         S   sT   t  |  ƒ \ } } | i p d S| i o | | i ƒ  | i ƒ  f S|  d d f S(   Ni    i   (   i    i    (   R   R^   RT   t   argmaxR_   (   RN   t   rept   cnt(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _mode1D  s    

i    i   (   RJ   RK   RL   R`   R–   t   listR•   t   sliceR^   t   tupleR”   (   RN   RO   Rž   Rj   t   newshapet   slicest   modesR†   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR     s    	*


c         C   s=   t  i | ƒ } t i | d j  | d ƒ } t i |  | | ƒ S(   Ng      ð?(   Ra   RM   RK   t   wheret   specialt   betainc(   RN   RR   R   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR      s    c         C   s   t  i t i |  ƒ d ƒ S(   s+   Returns the sign of x, or 0 if x is masked.i    (   RK   R‹   Ra   t   sign(   R   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   +  s    c         C   s–  t  |  | ƒ \ }  } } |  i ƒ  | i ƒ  }  } t i t i |  ƒ t i | ƒ ƒ } | | i ƒ  8} | d } | d j  o t t f S|  i ƒ  | i ƒ  } } |  | | | } } | t i i	 | | ƒ }	 | t i
 t i | | ƒ t i | | ƒ ƒ }
 |	 |
 } t | d ƒ } t | d ƒ } | d } t i
 | d | d | ƒ | } | t j o
 d } n# t d | d | | | | ƒ } | | f S(   s˜  Calculates a Pearson correlation coefficient and the p-value for testing
    non-correlation.

    The Pearson correlation coefficient measures the linear relationship
    between two datasets. Strictly speaking, Pearson's correlation requires
    that each dataset be normally distributed. Like other correlation
    coefficients, this one varies between -1 and +1 with 0 implying no
    correlation. Correlations of -1 or +1 imply an exact linear
    relationship. Positive correlations imply that as x increases, so does
    y. Negative correlations imply that as x increases, y decreases.

    The p-value roughly indicates the probability of an uncorrelated system
    producing datasets that have a Pearson correlation at least as extreme
    as the one computed from these datasets. The p-values are not entirely
    reliable but are probably reasonable for datasets larger than 500 or so.

    Parameters
    ----------
    x : 1D array
    y : 1D array the same length as x

    Returns
    -------
    (Pearson's correlation coefficient,
     2-tailed p-value)

    References
    ----------
    http://www.statsoft.com/textbook/glosp.html#Pearson%20Correlation
    i   i    g      ð?g      ð¿g        g      à?(   RX   RL   RK   t   mask_orRx   Ry   RH   R   t   addt   reducet   sqrtt   dott   minR_   R   (   R   t   yRk   Rn   t   dft   mxt   myt   xmt   ymt   r_numt   r_denR‘   t   tt   prob(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   4  s(    $
/

#
"c         C   sa  t  |  | ƒ \ }  } } |  i ƒ  | i ƒ  }  } t i t i |  ƒ t i | ƒ ƒ } | | i ƒ  8} | t j	 o: t i |  d | d t ƒ}  t i | d | d t ƒ} n | d } | d j  o t	 d ƒ ‚ n t
 |  ƒ } t
 | ƒ } t i i | | d ƒ } | ob t |  ƒ }	 t | ƒ }
 t i d „  |	 i ƒ  Dƒ ƒ d } t i d „  |
 i ƒ  Dƒ ƒ d } n d } } | | d d	 d
 } | d j p | d j o= | | | | } | t i | d | | d | ƒ :} n d | | } t i t i | | d d | ƒ ƒ | } | t j o
 d } n# t d | d | | | | ƒ } | | f S(   sŸ  Calculates a Spearman rank-order correlation coefficient and the p-value
    to test for non-correlation.

    The Spearman correlation is a nonparametric measure of the linear
    relationship between two datasets. Unlike the Pearson correlation, the
    Spearman correlation does not assume that both datasets are normally
    distributed. Like other correlation coefficients, this one varies
    between -1 and +1 with 0 implying no correlation. Correlations of -1 or
    +1 imply an exact linear relationship. Positive correlations imply that
    as x increases, so does y. Negative correlations imply that as x
    increases, y decreases.

    Missing values are discarded pair-wise: if a value is missing in x, the
    corresponding value in y is masked.

    The p-value roughly indicates the probability of an uncorrelated system
    producing datasets that have a Spearman correlation at least as extreme
    as the one computed from these datasets. The p-values are not entirely
    reliable but are probably reasonable for datasets larger than 500 or so.

Parameters
----------
    x : 1D array
    y : 1D array the same length as x
        The lengths of both arrays must be > 2.
    use_ties : {True, False} optional
        Whether the correction for ties should be computed.

Returns
-------
    (Spearman correlation coefficient,
     2-tailed p-value)

    References
    ----------
    [CRCProbStat2000] section 14.7
    RZ   Rp   i   i    s'   The input must have at least 3 entries!c         s   s/   x( |  ]! \ } } | | | d  d Vq Wd S(   i   i   N(    (   t   .0Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>©  s   	 g      (@c         s   s/   x( |  ]! \ } } | | | d  d Vq Wd S(   i   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>ª  s   	 i   g      @g      ð?g        g      à?(   RX   RL   RK   R©   Rx   Ry   RI   R`   Rd   RU   R    Ra   Rª   R«   R   t	   iteritemsR¬   t   divideRH   R   (   R   R¯   t   use_tiesRk   Rn   R°   t   rankxt   rankyt   dsqt   xtiest   ytiest   corr_xt   corr_yt   denomt   rhoR·   R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR*   p  s:    &$
#'
++
"c   !      C   sb  t  |  | ƒ \ }  } } |  i ƒ  | i ƒ  }  } t i t i |  ƒ t i | ƒ ƒ } | t j	 oJ t i |  d | d t ƒ}  t i | d | d t ƒ} | | i ƒ  8} n | d j  o t	 i
 t	 i
 f St i t |  d | ƒd ƒ } t i t | d | ƒd ƒ } | i ƒ  } | | | | } } t	 i g  }	 t t | ƒ d ƒ D]D }
 |	 | |
 d | |
 j | |
 d | |
 j i d ƒ i ƒ  qH~	 d t ƒ} t	 i g  } t t | ƒ d ƒ D]D }
 | | |
 d | |
 j  | |
 d | |
 j i d ƒ i ƒ  q¿~ d t ƒ} | oß t |  ƒ } t | ƒ } t	 i g  } | i ƒ  D] \ } } | | | | d qK~ d t ƒ} t	 i g  } | i ƒ  D] \ } } | | | | d q“~ d t ƒ} t i | | d | d | | d | d ƒ } n | | d d } | | | } | | d d | d	 } | oÁ| t	 i d
 „  | i ƒ  Dƒ ƒ 8} | t	 i d „  | i ƒ  Dƒ ƒ 8} t	 i g  } | i ƒ  D] \ } } | | | | d q™~ d t ƒt	 i g  } | i ƒ  D] \ } } | | | | d qÞ~ d t ƒ} | d | | d :} | d j oÀ t	 i g  } | i ƒ  D]' \ } } | | | | d | d qJ~ d t ƒt	 i g  } | i ƒ  D]' \ } } | | | | d | d q—~ d t ƒ} | d | | d | d :} qd } n d } } | d :} | | | 7} | | t	 i | ƒ } t i t | ƒ t	 i d ƒ ƒ }  | |  f S(   sD  Computes Kendall's rank correlation tau on two variables *x* and *y*.

    Parameters
    ----------
    xdata: sequence
        First data list (for example, time).
    ydata: sequence
        Second data list.
    use_ties: {True, False} optional
        Whether ties correction should be performed.
    use_missing: {False, True} optional
        Whether missing data should be allocated a rank of 0 (False) or the
        average rank (True)

    Returns
    -------
        tau : float
            Kendall tau
        prob : float
            Approximate 2-side p-value.
    RZ   Rp   i   R‚   i    i   RY   g       @i   c         s   s;   x4 |  ]- \ } } | | | d  d | d d Vq Wd S(   i   i   i   g      ð?N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>ñ  s   	 c         s   s;   x4 |  ]- \ } } | | | d  d | d d Vq Wd S(   i   i   i   g      ð?N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>ò  s   	 g      "@g      2@(   RX   t   flattenRK   R©   Rx   RI   R`   Rd   Ry   Ra   t   nant   masked_equalR    R‰   t   rangeR[   R‹   Rc   R   Rº   R¬   R¦   t   erfct   abs(!   R   R¯   R¼   R‚   Rk   Rn   t   rxt   ryR   Rl   t   it   Ct   _[2]t   DRÀ   RÁ   t   _[3]Rm   Ro   RÂ   t   _[4]RÃ   RÄ   t   taut   var_st   _[5]t   _[6]Rv   t   _[7]t   _[8]Rw   RC   R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   ¼  sZ    $jjHH7##EIGG
"


"c      
      s)  t  i ˆ d t d t d d ƒ‰ ˆ i \ } } ˆ i d ƒ } t i ‡ f d †  t | ƒ Dƒ ƒ } | i ƒ  } ˆ i ƒ  } t	 ˆ i
 ƒ  ƒ } t i d „  | i ƒ  Dƒ ƒ } t  i d | | d	 | | d	 | ƒ d
 }	 t ˆ d d d t ƒ}
 t  i | | f d t ƒ} t  i | | f d t ƒ} t  i | d t ƒ} x|t | ƒ D]n‰ t	 ˆ d d … ˆ f i
 ƒ  ƒ } t i d „  | i ƒ  Dƒ ƒ } | ˆ | ˆ d	 } xï t ˆ | d	 ƒ D]Û ‰  t i ‡  ‡ ‡ f d †  t | ƒ Dƒ ƒ | ˆ ˆ  f <| ˆ ˆ  f d |
 d d … ˆ f |
 d d … ˆ  f i ƒ  | | ˆ d	 | ˆ  d	 d | ˆ ˆ  f <| ˆ ˆ  f | ˆ  ˆ f <| ˆ ˆ  f | ˆ  ˆ f <q¼Wt  i | | | ƒ d
 | ˆ <qLW| i ƒ  } t | ƒ t | ƒ d	 t  i | ƒ } t | ƒ t | ƒ d	 t  i | i ƒ  ƒ } t | ƒ t | ƒ d	 t  i | i ƒ  ƒ } t i t | ƒ t i d ƒ ƒ } t i t | ƒ t i d ƒ ƒ } t i t | ƒ t i d ƒ ƒ } | | i ƒ  } | | i ƒ  d } h | | d 6| |	 d 6| | i ƒ  d 6| d 6| d 6| d 6| d 6| d 6} | S(   sÆ   Computes a multivariate extension Kendall's rank correlation tau, designed
    for seasonal data.

Parameters
----------
    x: 2D array
        Array of seasonal data, with seasons in columns.
    t   subokRp   t   ndmini   i    c         3   s4   x- |  ]& } t  ˆ  | ˆ  | ƒ i d  ƒ Vq Wd S(   i    N(   R   Ry   (   R¹   RÎ   (   R   (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>  s   	 c         s   s+   x$ |  ] \ } } | | | d  Vq Wd S(   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>  s   	 g      ð?i   g       @RO   R‚   RY   Nc         s   s+   x$ |  ] \ } } | | | d  Vq Wd S(   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>#  s   	 c         3   se   x^ |  ]W } t  ˆ | d  … ˆ f ˆ | ˆ f ˆ | d  … ˆ  f ˆ | ˆ  f ƒ i ƒ  Vq Wd  S(   N(   R   Ry   (   R¹   RÎ   (   Rm   t   jR   (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>&  s   	i   g      @s   seasonal taus
   global taus   global tau (alt)s   seasonal p-values   global p-value (indep)s   global p-value (dep)s
   chi2 totals
   chi2 trend(   RK   R`   Rd   RŒ   R•   Rˆ   Ra   Ry   RÉ   R   Rq   Rº   R¬   R    Rb   t   intRc   t   diagonalR   RË   R¦   RÊ   R   (   R   Rk   Rn   t   n_pt   S_sznt   S_tott   n_totR…   t	   corr_tiest	   denom_tott   Rt   Kt   covmatt	   denom_sznt   ties_jt   corr_jt   cmbt   var_sznt   z_sznt	   z_tot_indt	   z_tot_dept   prob_sznt   prob_tot_indt   prob_tot_dept   chi2_tott   chi2_trdRj   (    (   Rm   RÜ   R   sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR     sZ    	!%/ " ?-#'--"""
c         C   sa  t  i |  d t ƒi t ƒ }  t  i | d t ƒi t ƒ } t  i t  i |  ƒ t  i | ƒ ƒ } | t j	 o' t	 i
 | ƒ } |  | }  | | } n t |  ƒ } |  i ƒ  t | ƒ } | |  } | |  } | i ƒ  } | i ƒ  }	 |	 | t	 i | d | ƒ | i ƒ  }
 | d } |
 t  i | d |
 d ƒ } t d | d | | | | ƒ } |
 | f S(   NRp   i   i   g      ð?g      à?(   RK   t   fix_invalidRd   t   astypet   boolRc   R©   Rx   RI   Ra   Rf   R[   Ry   R   R¬   R%   R   (   R   R¯   Rn   t   unmaskRk   t   phatt   y0t   y1t   y0mt   y1mt   rpbR°   R·   R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   H  s$    $

)
"c          G   s~  t  |  ƒ d j ot t i |  d d t ƒ}  t  |  ƒ d j o |  d } |  d } q¹ |  d  d  … d f } |  d  d  … d f } n3 t i |  d ƒ i ƒ  } t i |  d ƒ i ƒ  } t i t i | ƒ t i | ƒ ƒ } | t j	 o. t i | d | ƒ} t i | d | ƒ} n t  | ƒ } | i ƒ  | i ƒ  } } | | | | } } t i	 i
 | | ƒ t i	 i
 | | ƒ }	 }
 t i	 i
 | | ƒ } t i |	 |
 ƒ } | d j o
 d } n" | | } | d j o
 d } n | d } | t i | d | | ƒ } t d | d | | | | ƒ } | |	 } | | | } t i d | | ƒ | i ƒ  } | | | | | |
 |	 f S(	   Ni   i    Rp   i   RZ   g        g      ð?g      à?(   R[   RK   R`   Rd   RÆ   R©   Rx   RI   R   Rª   R«   R¬   R   R%   (   Ri   R   R¯   Rn   Rk   t   xmeant   ymeanR³   R´   t   Sxxt   Syyt   SxyR¶   R‘   R°   R·   R¸   t   slopet	   interceptt   sterrest(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   e  s>    
$-



"
!gš™™™™™©?c      
   C   s½  t  i |  ƒ i ƒ  }  t |  d <t |  ƒ } | d j o t  i t |  ƒ d t ƒ} nF t  i | ƒ i ƒ  } t | ƒ | j o t d | t | ƒ f ‚ n t  i	 t  i
 | ƒ t  i
 |  ƒ ƒ } | |  _ | _ |  i ƒ  } t  i g  } t | d ƒ D]1 } | |  | d |  | | | d | | q÷ ~ ƒ } | i ƒ  t  i | ƒ }	 t  i |  ƒ |	 t  i | ƒ }
 | d j o d | } n t i i i | d ƒ } t | ƒ t |  ƒ } } | | d d } | | d d | d	 d
 } | t i d „  | i ƒ  Dƒ ƒ 8} | t i d „  | i ƒ  Dƒ ƒ 8} t i | ƒ } t t i | | | d d ƒ t | ƒ d ƒ } t t i | | | d ƒ d ƒ } | | | g } |	 |
 | d | d f S(   sÃ  Computes the Theil slope over the dataset (x,y), as the median of all slopes
    between paired values.

    Parameters
    ----------
        y : sequence
            Dependent variable.
        x : {None, sequence} optional
            Independent variable. If None, use arange(len(y)) instead.
        alpha : float
            Confidence degree.

    Returns
    -------
        medslope : float
            Theil slope
        medintercept : float
            Intercept of the Theil line, as median(y)-medslope*median(x)
        lo_slope : float
            Lower bound of the confidence interval on medslope
        up_slope : float
            Upper bound of the confidence interval on medslope

    iÿÿÿÿRY   s   Incompatible lengths ! (%s<>%s)i   g      à?g      ð?g       @i   i   g      2@c         s   s7   x0 |  ]) \ } } | | | d  d | d Vq Wd S(   i   i   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>À  s   	 c         s   s7   x0 |  ]) \ } } | | | d  d | d Vq Wd S(   i   i   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>Á  s   	 i    N(   RK   R]   RÆ   RH   R[   RJ   RŠ   Rc   RU   R©   Rx   t   _maskRˆ   t   hstackRÉ   t   sortt   mediant   statst   distributionst   normt   ppfR   Ra   Ry   Rº   R¬   R®   t   roundR_   (   R¯   R   t   alphaRk   Rn   t   nyRl   RÎ   t   slopest   medslopet   medinterRC   RÀ   RÁ   t   ntt   sigsqt   sigmat   Rut   Rlt   delta(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR,   Ž  s8    
$X
 ##2$c      
   C   sÈ   t  i |  d t d t d d ƒ}  |  i \ } } t  i g  } t | ƒ D]A } | |  | d |  | t i d | | ƒ d  d  … d  f qG ~ ƒ } t  i
 | d d ƒ} t  i
 | d d  ƒ} | | f S(   NRÚ   Rp   RÛ   i   i   RO   i    (   RK   R`   Rd   RŒ   R•   t   vstackRÉ   Ra   RŠ   RJ   R
  (   R   Rk   t   _Rl   RÎ   t
   szn_slopest   szn_medslopesR  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR&   Ê  s    !Wc   	      C   s¸   t  i |  ƒ }  |  i d d  ƒ } |  i d d  d d ƒ } |  i d d  ƒ } | d } | d | t | ƒ } | | t  i | d | ƒ } t d | d | | | | ƒ } | | f S(   NRO   t   ddofi   g      ð?g      à?(	   RK   R]   R   RJ   R@   Rˆ   Rc   R¬   R   (	   RN   t   popmeanR   Ro   Rk   R°   t   svarR·   R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR<   Ù  s    
"c         C   sC  t  |  | | ƒ \ }  } } |  i | ƒ | i | ƒ } } |  i d | d d ƒ | i d | d d ƒ } } |  i | ƒ | i | ƒ } } | | d }	 | d | | d | t |	 ƒ }
 |
 d j | | t i |
 d | d | ƒ } t i | d ƒ } t d |	 d t |	 ƒ |	 | | ƒ i	 | i
 ƒ } | | i ƒ  f S(   NRO   R  i   i   i    g      ð?g      à?(   RS   R   R@   Rˆ   Rc   RK   R¬   R‹   R   R”   R•   t   squeeze(   RN   RR   RO   t   x1t   x2Rv   Rw   t   n1t   n2R°   R!  R·   t   probs(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR=   ç  s    1$
'4c         C   sg  t  |  | | ƒ \ }  } } t |  ƒ t | ƒ j o t d ‚ n |  i | ƒ | i | ƒ } } |  i d | d d ƒ | i d | d d ƒ } } |  i | ƒ } | d } |  | i d ƒ }	 t i | t i	 i
 |	 |	 | ƒ t i	 i
 |	 | ƒ d | ƒ }
 t i	 i
 |	 | ƒ |
 } t i | d ƒ } t d | d | | | | ƒ i | i ƒ i ƒ  } | | f S(	   Ns   unequal length arraysRO   R  i   g      ð?t   di   g      à?(   RS   R[   RU   R   R@   Rˆ   Rö   RK   R¬   Rª   R«   R‹   R   R”   R•   R"  (   RN   RR   RO   R#  R$  Rv   Rw   Rk   R°   R(  RÄ   R·   R'  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR>   ö  s    1
A4c         C   s˜   t  i |  ƒ }  | d  j o, t  i |  i d d ƒ g t |  ƒ ƒ } n | i t ƒ } t  i i	 |  | d | ƒ } | t
 i | |  i d ƒ d ƒ f S(   NRO   i    i   i   (   RK   R]   RJ   R`   R   R[   Rö   Rc   Rª   R«   R  t	   chisqprobRˆ   (   t   f_obst   f_expt   chisq(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR     s    ,c         C   sŸ  t  i |  ƒ i ƒ  i t ƒ }  t  i | ƒ i ƒ  i t ƒ } t t i |  | g ƒ ƒ } t |  ƒ t | ƒ } } | | } | |  i	 ƒ  | | d d } t
 | | | | ƒ } | | | } | | d }	 | d | d }
 t | ƒ } |
 t i	 d „  | i ƒ  Dƒ ƒ d 8}
 |
 | | t | | d ƒ 9}
 | o# | d d |	 t  i |
 ƒ } n | |	 t  i |
 ƒ } t i t | ƒ t i d ƒ ƒ } | | f S(   sÕ  Computes the Mann-Whitney on samples x and y.
    Missing values in x and/or y are discarded.

    Parameters
    ----------
        x : sequence
        y : sequence
        use_continuity : {True, False} optional
            Whether a continuity correction (1/2.) should be taken into account.

    Returns
    -------
        u : float
            The Mann-Whitney statistics
        prob : float
            Approximate p-value assuming a normal distribution.

    i   g       @i   g      (@c         s   s+   x$ |  ] \ } } | | d  | Vq Wd S(   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>1  s   	 i   (   RK   R]   Rq   R—   RF   R    Ra   t   concatenateR[   Ry   R_   R   Rº   Rc   R¬   R¦   RÊ   RË   (   R   R¯   t   use_continuityt   rankst   nxR  R  t   Ut   ut   muR  R…   RC   R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR     s$    
 ' #"c          G   s  t  |  Œ  } t i t | d t ƒd ƒ } | i d ƒ } | i d ƒ } | i ƒ  } d | | d | d | i ƒ  d | d } t | ƒ } d t i d	 „  | i	 ƒ  Dƒ ƒ t
 | d | ƒ } | d j o t d
 ‚ n | | :} t | ƒ d }	 t i | |	 ƒ }
 | |
 f S(   NR‚   i    iÿÿÿÿg      (@i   i   i   g      ð?c         s   s+   x$ |  ] \ } } | | d  | Vq Wd S(   i   N(    (   R¹   Rm   Ro   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pys	   <genexpr>G  s   	 s$   All numbers are identical in kruskal(   R    RK   RÈ   R    RŒ   Ry   Rˆ   R   Ra   Rº   Rc   RU   R[   R  R)  (   Ri   Rj   R/  t   sumrkt   ngrpt   ntott   HR…   t   TR°   R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   <  s    05
c         C   sÅ   |  d j o d S|  d j o d St  i t  i | d |  ƒ d ƒ } d |  t  i t  i t  i t i | | ƒ ƒ | | t  i d |  | t | ƒ ƒ | d t  i |  | t | ƒ ƒ ƒ ƒ S(   Ni    i   (	   Ra   RŠ   t   floorRy   R™   R˜   t   misct   combRc   (   R   Rk   RÜ   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _kolmog1T  s    $t	   two_sidedc         C   sÚ  t  i |  ƒ t  i | ƒ }  } |  i ƒ  | i ƒ  } } | | t | | ƒ } t  i |  i ƒ  | i ƒ  f ƒ } | i d d ƒ } t i | | j  d | d | ƒ i	 ƒ  } t
 t i | ƒ ƒ | | j  o2 | t i t i | | ƒ i ƒ  d d f } n t | ƒ i ƒ  d } | d j o2 t  i | ƒ i ƒ  }	 t t i | ƒ |	 ƒ }
 n~ | d j o, | i ƒ  }	 t i d	 | |	 d
 ƒ }
 nE | d j o+ | i ƒ  }	 t i d	 | |	 d
 ƒ }
 n t d ƒ ‚ |	 |
 f S(   sç  Computes the Kolmogorov-Smirnov test on two samples.
    Missing values are discarded.

    Parameters
    ----------
        data1 : sequence
            First data set
        data2 : sequence
            Second data set
        alternative : {'two_sided', 'less', 'greater'} optional
            Indicates the alternative hypothesis.

    Returns
    -------
        d : float
            Value of the Kolmogorov Smirnov test
        p : float
            Corresponding p-value.

    t   kindt	   mergesortg      ð?g      ð¿i    iÿÿÿÿR·   t   liþÿÿÿi   t   gs[   Invalid value for the alternative hypothesis: should be in 'two_sided', 'less' or 'greater'(   RK   R]   Rˆ   Rc   R-  Rq   R‰   Ra   R¥   t   cumsumR[   R|   t   r_t   difft   nonzerot   strt   lowerRË   R_   t   _kolmog2R¬   R®   R™   RU   (   t   data1t   data2t   alternativeR%  R&  Rk   t   mixt   mixsortt   csumR(  R¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   _  s(    !) 2c         C   sL   g  } |  | f D] } | t  i | ƒ i ƒ  q ~ \ }  } t i |  | ƒ S(   s_    Computes the Kolmogorov-Smirnov statistic on 2 samples.
    Returns: KS D-value, p-value
    #(   RK   R]   Rq   R  R   (   RI  RJ  Rl   R(  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   ks_twosamp_old  s    <c         C   s   t  i |  d t ƒ}  t i |  i d t ƒ} | d j	 o | |  | j  i t	 ƒ O} n | d j	 o | |  | j i t	 ƒ O} n | |  | <|  S(   sp  Clip array to a given value.

Similar to numpy.clip(), except that values less than threshmin or
greater than threshmax are replaced by newval, instead of by
threshmin and threshmax respectively.

Parameters
----------
    a : ndarray
        Input data
    threshmin : {None, float} optional
        Lower threshold. If None, set to the minimum value.
    threshmax : {None, float} optional
        Upper threshold. If None, set to the maximum value.
    newval : {0, float} optional
        Value outside the thresholds.

Returns
-------
    a, with values less (greater) than threshmin (threshmax) replaced with newval.

Rp   RY   N(
   RK   R`   Rd   Ra   t   zerosR•   R÷   RJ   R‹   RŒ   (   RN   t	   threshmint	   threshmaxt   newvalRZ   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR-   ›  s    
c         C   sØ   t  i |  ƒ }  |  i ƒ  | d j o |  S| \ } } | \ } } t } | d j	 o/ | o | |  | j  O} q… | |  | j O} n | d j	 o/ | o | |  | j O} qÁ | |  | j O} n t |  | i t ƒ <|  S(   s`  Trims an array by masking the data outside some given limits.
    Returns a masked version of the input array.

    Parameters
    ----------
    a : sequence
        Input array.
    limits : {None, tuple} optional
        Tuple of (lower limit, upper limit) in absolute values.
        Values of the input array lower (greater) than the lower (upper) limit
        will be masked. A limit is None indicates an open interval.
    inclusive : {(True,True) tuple} optional
        Tuple of (lower flag, upper flag), indicating whether values exactly
        equal to the lower (upper) limit are allowed.

    N(   RK   R]   t   unshare_maskRJ   RŒ   RH   R‹   Rd   (   RN   t   limitst	   inclusivet	   lower_limt	   upper_limt   lower_int   upper_inR’   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR4   ¼  s"    
c         C   s?  d „  } t  i |  ƒ }  |  i ƒ  | d j o |  S| \ } } d } | d j	 o: | d j p | d j  o t | d d | ƒ ‚ q n | d j	 o: | d j p | d j  o t | d d | ƒ ‚ qÔ n | \ } }	 | d j o/ |  i }
 | |  i ƒ  | | | |	 ƒ i |
 ƒ St  i | | |  | | | |	 ƒ Sd S(	   s  Trims an array by masking some proportion of the data on each end.
    Returns a masked version of the input array.

    Parameters
    ----------
    a : sequence
        Input array.
    limits : {None, tuple} optional
        Tuple of the percentages to cut on each side of the array, with respect
        to the number of unmasked data, as floats between 0. and 1.
        Noting n the number of unmasked data before trimming, the (n*limits[0])th
        smallest data and the (n*limits[1])th largest data are masked, and the
        total number of unmasked data after trimming is n*(1.-sum(limits))
        The value of one limit can be set to None to indicate an open interval.
    inclusive : {(True,True) tuple} optional
        Tuple of flags indicating whether the number of data being masked on the
        left (right) end should be truncated (True) or rounded (False) to integers.
    axis : {None,int} optional
        Axis along which to trim. If None, the whole array is trimmed, but its
        shape is maintained.

    c   	      S   s¸   |  i  ƒ  } |  i ƒ  } | o@ | o t | | ƒ } n t i | | ƒ } t |  | |  <n | d  j	 oH | o | t | | ƒ } n | t i | | ƒ } t |  | | <n |  S(   N(   Rˆ   R‰   RÝ   Ra   R  RH   RJ   (	   RN   t	   low_limitt   up_limitt   low_inclusivet   up_inclusiveRk   R   t   lowidxt   upidx(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _trimr1Dù  s    s=   The proportion to cut from the %s should be between 0. and 1.g      ð?i    t	   beginnings   (got %s)t   endN(	   RK   R]   RT  RJ   RU   R•   RL   R”   R–   (   RN   RU  RV  RO   Ra  t   lolimt   uplimt   errmsgt   loinct   upinct   shp(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR5   â  s$    	
  	&sU  
    Parameters
    ----------
    a : sequence
        Input array
    limits : {None, tuple} optional
        If relative == False, tuple (lower limit, upper limit) in absolute values.
        Values of the input array lower (greater) than the lower (upper) limit are
        masked.
        If relative == True, tuple (lower percentage, upper percentage) to cut
        on each side of the  array, with respect to the number of unmasked data.
        Noting n the number of unmasked data before trimming, the (n*limits[0])th
        smallest data and the (n*limits[1])th largest data are masked, and the
        total number of unmasked data after trimming is n*(1.-sum(limits))
        In each case, the value of one limit can be set to None to indicate an
        open interval.
        If limits is None, no trimming is performed
    inclusive : {(True, True) tuple} optional
        If relative==False, tuple indicating whether values exactly equal to the
        absolute limits are allowed.
        If relative==True, tuple indicating whether the number of data being masked
        on each side should be rounded (True) or truncated (False).
    relative : {False, True} optional
        Whether to consider the limits as absolute values (False) or proportions
        to cut (True).
    axis : {None, integer}, optional
        Axis along which to trim.
c         C   s>   | o t  |  d | d | d | ƒSt |  d | d | ƒSd S(   sY  Trims an array by masking the data outside some given limits.
    Returns a masked version of the input array.
   %s

    Examples
    --------
        >>>z = [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10]
        >>>trim(z,(3,8))
        [--,--, 3, 4, 5, 6, 7, 8,--,--]
        >>>trim(z,(0.1,0.2),relative=True)
        [--, 2, 3, 4, 5, 6, 7, 8,--,--]


    RU  RV  RO   N(   R5   R4   (   RN   RU  RV  t   relativeRO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR1   >  s    gš™™™™™É?c         C   s"   t  |  d | | f d | d | ƒS(   sI  Trims the data by masking the int(proportiontocut*n) smallest and
    int(proportiontocut*n) largest values of data along the given axis, where n
    is the number of unmasked values before trimming.

Parameters
----------
    data : ndarray
        Data to trim.
    proportiontocut : {0.2, float} optional
        Percentage of trimming (as a float between 0 and 1).
        If n is the number of unmasked values before trimming, the number of
        values after trimming is:
            (1-2*proportiontocut)*n.
    inclusive : {(True, True) tuple} optional
        Tuple indicating whether the number of data being masked on each side
        should be rounded (True) or truncated (False).
    axis : {None, integer}, optional
        Axis along which to perform the trimming.
        If None, the input array is first flattened.

    RU  RV  RO   (   R5   (   R„   t   proportiontocutRV  RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR2   V  s    t   leftc         C   sx   t  | ƒ i ƒ  d } | d j o | d f } n* | d j o d | f } n t d ƒ ‚ t |  d | d | d | ƒS(	   si  Trims the data by masking int(trim*n) values from ONE tail of the
    data along the given axis, where n is the number of unmasked values.

Parameters
----------
    data : {ndarray}
        Data to trim.
    proportiontocut : {0.2, float} optional
        Percentage of trimming. If n is the number of unmasked values
        before trimming, the number of values after trimming is
        (1-proportiontocut)*n.
    tail : {'left','right'} optional
        If left (right), the ``proportiontocut`` lowest (greatest) values will
        be masked.
    inclusive : {(True, True) tuple} optional
        Tuple indicating whether the number of data being masked on each side
        should be rounded (True) or truncated (False).
    axis : {None, integer}, optional
        Axis along which to perform the trimming.
        If None, the input array is first flattened.

    i    R@  R‘   s/   The tail argument should be in ('left','right')RU  RO   RV  N(   RF  RG  RJ   t	   TypeErrorR5   (   R„   Rk  t   tailRV  RO   RU  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR3   p  s    gš™™™™™¹?i   c         C   s   d t  t | t ƒ o  t | t ƒ o | | f } n | o) t |  d | d | d | ƒi d | ƒ St |  d | d | ƒi d | ƒ Sd  S(   NsH   Returns the trimmed mean of the data along the given axis.

    %s

    RU  RV  RO   (   t   trimdocR\   R¡   Rc   R5   R   R4   (   RN   RU  RV  Rj  RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR6   “  s    !)c         C   s   d t  t | t ƒ o  t | t ƒ o | | f } n | o" t |  d | d | d | ƒ} n t |  d | d | ƒ} | i d | d | ƒ S(   Ns6  Returns the trimmed variance of the data along the given axis.

    %s
    ddof : {0,integer}, optional
        Means Delta Degrees of Freedom. The denominator used during computations
        is (n-ddof). DDOF=0 corresponds to a biased estimate, DDOF=1 to an un-
        biased estimate of the variance.

    RU  RV  RO   R  (   Ro  R\   R¡   Rc   R5   R4   R@   (   RN   RU  RV  Rj  RO   R  t   out(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR9   ¢  s    
!"c         C   s   d t  t | t ƒ o  t | t ƒ o | | f } n | o" t |  d | d | d | ƒ} n t |  d | d | ƒ} | i d | d | ƒ S(   Ns@  Returns the trimmed standard deviation of the data along the given axis.

    %s
    ddof : {0,integer}, optional
        Means Delta Degrees of Freedom. The denominator used during computations
        is (n-ddof). DDOF=0 corresponds to a biased estimate, DDOF=1 to an un-
        biased estimate of the variance.

    RU  RV  RO   R  (   Ro  R\   R¡   Rc   R5   R4   R%   (   RN   RU  RV  Rj  RO   R  Rp  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR7   ¶  s    
!"c         C   sµ  d „  } t  i |  d t d t ƒ}  |  i ƒ  | d j o- |  i d | d d ƒ t  i |  i | ƒ ƒ St | t	 ƒ o  t | t
 ƒ o | | f } n | \ } } d } | d j	 o: | d j p | d	 j  o t | d
 d | ƒ ‚ qò n | d j	 o: | d j p | d	 j  o t | d d | ƒ ‚ q9n | \ } }	 | d j o& |  i }
 | |  i ƒ  | | | |	 ƒ S|  i d j p
 t d ‚ t  i | | |  | | | |	 ƒ Sd S(   sÙ  Returns the standard error of the trimmed mean of the data along the given
    axis.
    Parameters
    ----------
    a : sequence
        Input array
    limits : {(0.1,0.1), tuple of float} optional
        tuple (lower percentage, upper percentage) to cut  on each side of the
        array, with respect to the number of unmasked data.
        Noting n the number of unmasked data before trimming, the (n*limits[0])th
        smallest data and the (n*limits[1])th largest data are masked, and the
        total number of unmasked data after trimming is n*(1.-sum(limits))
        In each case, the value of one limit can be set to None to indicate an
        open interval.
        If limits is None, no trimming is performed
    inclusive : {(True, True) tuple} optional
        Tuple indicating whether the number of data being masked on each side
        should be rounded (True) or truncated (False).
    axis : {None, integer}, optional
        Axis along which to trim.
    c      	   S   s%  |  i  ƒ  } |  i ƒ  } | o@ | o t | | ƒ } n t i | | ƒ } t |  | |  <n | d j	 oH | o | t | | ƒ } n | t i | | ƒ } t |  | | <n |  i  ƒ  }	 |  | | |  | |  <|  | | d |  | | <|  i d d ƒ }
 |
 d | | t i t	 |  ƒ ƒ S(   sC   Returns the standard error of the trimmed mean for a 1D input data.i   R  N(
   Rˆ   R‰   RÝ   Ra   R  RH   RJ   R%   R¬   R[   (   RN   R[  R\  R]  R^  Rk   R   R_  R`  t   nsizet   winstd(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _trimmed_stde_1Dá  s"    Rp   RÚ   RO   R  i   s=   The proportion to cut from the %s should be between 0. and 1.g      ð?i    Rb  s   (got %s)Rc  i   s   Array should be 2D at most !N(   RK   R`   Rd   RT  RJ   R%   R¬   Rˆ   R\   R¡   Rc   RU   R•   RL   R^   t   AssertionErrorR–   (   RN   RU  RV  RO   Rs  Rd  Re  Rf  Rg  Rh  Ri  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR8   Ê  s,    	
-!  	c         C   s   t  |  d | d | ƒi ƒ  S(   NRU  RV  (   R4   R   (   RN   RU  RV  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR/     s    c         C   s   t  |  d | d | ƒi ƒ  S(   NRU  RV  (   R4   R@   (   RN   RU  RV  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR?     s    c         C   sF   t  |  | ƒ \ }  } t |  | d  f | t f ƒ } t i i | | ƒ S(   N(   RQ   R4   RJ   RŒ   RK   t   minimumR«   (   RN   t
   lowerlimitRO   RV  t   am(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR0     s    c         C   sF   t  |  | ƒ \ }  } t |  d  | f t | f ƒ } t i i | | ƒ S(   N(   RQ   R4   RJ   RŒ   RK   t   maximumR«   (   RN   t
   upperlimitRO   RV  Rw  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR.     s    c         C   s‡   t  i |  ƒ i ƒ  }  | d  j o* t |  i ƒ  ƒ } |  i ƒ  t  i | ƒ St |  i ƒ  | | ƒ } t	 i | i
 ƒ  ƒ } | | i ƒ  S(   N(   RK   R]   RL   RJ   Rc   Rˆ   R%   R¬   R4   Ra   R@   (   RN   RU  RV  Rk   Rw  t   sd(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR:   %  s    c         C   su  d „  } t  i |  d t i | ƒ ƒ}  | d	 j o |  St | t ƒ o  t | t ƒ o | | f } n | \ } } d } | d	 j	 o: | d j p | d j  o t | d d | ƒ ‚ qÃ n | d	 j	 o: | d j p | d j  o t | d d | ƒ ‚ q
n | \ }	 }
 | d	 j o/ |  i	 } | |  i
 ƒ  | | |	 |
 ƒ i | ƒ St  i | | |  | | |	 |
 ƒ Sd	 S(
   sæ  Returns a Winsorized version of the input array.

    The (limits[0])th lowest values are set to the (limits[0])th percentile,
    and the (limits[1])th highest values are set to the (limits[1])th
    percentile.
    Masked values are skipped.


    Parameters
    ----------
    a : sequence
        Input array.
    limits : {None, tuple of float} optional
        Tuple of the percentages to cut on each side of the array, with respect
        to the number of unmasked data, as floats between 0. and 1.
        Noting n the number of unmasked data before trimming, the (n*limits[0])th
        smallest data and the (n*limits[1])th largest data are masked, and the
        total number of unmasked data after trimming is n*(1.-sum(limits))
        The value of one limit can be set to None to indicate an open interval.
    inclusive : {(True, True) tuple} optional
        Tuple indicating whether the number of data being masked on each side
        should be rounded (True) or truncated (False).
    inplace : {False, True} optional
        Whether to winsorize in place (True) or to use a copy (False)
    axis : {None, int} optional
        Axis along which to trim. If None, the whole array is trimmed, but its
        shape is maintained.

    c   	      S   sÌ   |  i  ƒ  } |  i ƒ  } | oH | o t | | ƒ } n t i | | ƒ } |  | | |  | |  <n | d  j	 oT | o | t | | ƒ } n | t i | | ƒ } |  | | d |  | | <n |  S(   Ni   (   Rˆ   R‰   RÝ   Ra   R  RJ   (	   RN   R[  R\  t   low_includet
   up_includeRk   R   R_  R`  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _winsorize1DN  s    Rp   s=   The proportion to cut from the %s should be between 0. and 1.g      ð?i    Rb  s   (got %s)Rc  N(   RK   R`   Ra   Rf   RJ   R\   R¡   Rc   RU   R•   RL   R”   R–   (   RN   RU  RV  t   inplaceRO   R}  Rd  Re  Rf  Rg  Rh  Ri  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyRB   0  s&    	!  	&c         C   s¬   t  |  | ƒ \ }  } | d j oB t |  i ƒ } | | =| o t i | d t ƒSt i d ƒ SnE t i |  i	 d | ƒ | ƒ } t i
 |  | | ƒ } | i	 d | ƒ Sd  S(   Ni   RY   g        RO   (   RQ   RŸ   R•   Ra   RP  Rc   t   float64RK   t   expand_dimsR   t   power(   RN   R   RO   R•   t   mnt   s(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   |  s    c         C   s/   t  |  | ƒ \ }  } |  i | ƒ |  i | ƒ S(   N(   RQ   R%   R   (   RN   RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyRA     s    c   	      C   s  t  |  | ƒ \ }  } |  i | ƒ } t |  d | ƒ } t |  d | ƒ } t i | d j d | | d ƒ } | p | d j | d j @} | i ƒ  of t i | | ƒ } t i | | ƒ } t i | d | ƒ | d | | d } t i	 | | | ƒ qÿ n | S(   Ni   i   i    g      ø?g      ð?g       @(
   RQ   Rˆ   R   RK   R¥   t   anyRa   t   extractR¬   t   place(	   RN   RO   t   biasRk   t   m2t   m3t   valst   can_correctt   nval(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR(   •  s    #+c   
      C   s.  t  |  | ƒ \ }  } |  i | ƒ } t |  d | ƒ } t |  d | ƒ } t i | d j d | | d ƒ } | p¤ | d j | d j @} | i ƒ  o} t i | | ƒ } t i | | ƒ } d | d | d | | d | | d d | d d }	 t i | | |	 d ƒ qn | o	 | d S| Sd  S(	   Ni   i   i    g       @i   g      ð?i   g      @(	   RQ   Rˆ   R   RK   R¥   R„  Ra   R…  R†  (
   RN   RO   t   fisherR‡  Rk   Rˆ  t   m4RŠ  R‹  RŒ  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   ¦  s    #>	c         C   sš   t  |  | ƒ \ }  } |  i | ƒ } t i i |  ƒ t i i |  ƒ f } |  i | ƒ } |  i | ƒ } t |  | ƒ } t	 |  | ƒ } | | | | | | f S(   s<  Computes several descriptive statistics of the passed array.

    Parameters
    ----------
    a : array
    axis : int or None

    Returns
    -------
    (size of the data (discarding missing values),
     (min, max),
     arithmetic mean,
     unbiased variance,
     biased skewness,
     biased kurtosis)
    (
   RQ   Rˆ   RK   Ru  R«   Rx  R   R@   R(   R   (   RN   RO   Rk   t   mmRn   Ro   t   skt   kurt(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   ¹  s    $c         C   sm   d „  } t  i |  d t d t ƒ}  | d j o | |  ƒ S|  i d j p
 t d ‚ t  i | | |  ƒ Sd S(   sj  Returns the McKean-Schrader estimate of the standard error of the sample
median along the given axis. masked values are discarded.

    Parameters
    ----------
        data : ndarray
            Data to trim.
        axis : {None,int} optional
            Axis along which to perform the trimming.
            If None, the input array is first flattened.

    c         S   s|   t  i |  i ƒ  ƒ }  t |  ƒ } d } t t  i | d d | t  i | d ƒ d ƒ ƒ } |  | | |  | d d | S(   Ng`‘ÖdL›@i   g       @g      @i    (   Ra   R	  Rq   R[   RÝ   R  R¬   (   R„   Rk   RC   Rm   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _stdemed_1Dá  s
    5Rp   RÚ   i   s   Array should be 2D at most !N(   RK   R`   RŒ   Rd   RJ   R^   Rt  R–   (   R„   RO   R’  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   stde_medianÔ  s    	c   
      C   s·  t  |  | ƒ \ }  } | d  j o |  i ƒ  }  d } n t |  | ƒ } |  i | ƒ } t i | ƒ d j  o t i d t i | ƒ ƒ n | t	 i
 | d | d d | d ƒ } d | | d	 | d
 | d | d | d | d | d | d } d t	 i
 d | d ƒ } d t	 i
 d t	 i | ƒ ƒ } t	 i
 d | d ƒ } t	 i | d j d | ƒ } | t	 i | | t	 i
 | | d d ƒ ƒ }	 |	 d t i |	 ƒ d f S(   Ni    i   s8   skewtest only valid for n>=8 ... continuing anyway, n=%ii   i   g      @i   g      @i   iF   g       @i   i   i	   iÿÿÿÿg      à?g      ð?(   RQ   RJ   RL   R(   Rˆ   Ra   R®   t   warningst   warnRK   R¬   R˜   R¥   R  t   zprob(
   RN   RO   t   b2Rk   R¯   t   beta2t   W2R  R  t   Z(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR)   ó  s$    
+J 0c         C   s  t  |  | ƒ \ }  } |  i d | ƒ i t ƒ } t i | ƒ d j  o t i d t i | ƒ ƒ n t |  | d t	 ƒ} d | d | d } d | | d | d	 | d | d | d	 | d
 } | | t
 i | ƒ } d | | d
 | d | d | d t i d | d	 | d
 | | d | d	 ƒ } d d | d | t i d d | d ƒ } d d d | }	 d | t
 i d | d ƒ }
 t |
 |
 d j  <t
 i d d | |
 d d ƒ } |	 | t i d d | ƒ } | d t i | ƒ d f S(   NRO   i   s=   kurtosistest only valid for n>=20 ... continuing anyway, n=%iR  g      @i   g      8@i   i   i   g      @i   i	   g       @g       @g      @g      "@i    g      ð?(   RQ   Rˆ   Rö   Rc   Ra   R®   R”  R•  R   RŒ   RK   R¬   RH   R  R  R–  (   RN   RO   Rk   R—  t   Et   varb2R   t	   sqrtbeta1t   At   term1RÄ   t   term2Rš  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR     s&    :@/"c         C   sg   t  |  | ƒ \ }  } t |  | ƒ \ } } t |  | ƒ \ } } | | | | } | t i | d ƒ f S(   Ni   (   RQ   R)   R   R  R)  (   RN   RO   Rƒ  R  Rm   t   k2(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR     s
    g      Ð?g      à?g      è?gš™™™™™Ù?c   
      C   sà   d „  } t  i |  d t ƒ}  | o5 | d |  j  |  | d j  @} t |  | i t ƒ <n t i | d t d d ƒ} | | d | | }	 | d	 j o | |  |	 | ƒ S|  i d j p
 t	 d ‚ t  i
 | | |  |	 | ƒ Sd	 S(
   s@  Computes empirical quantiles for a *1xN* data array.
Samples quantile are defined by:
*Q(p) = (1-g).x[i] +g.x[i+1]*
where *x[j]* is the jth order statistic,
with *i = (floor(n*p+m))*, *m=alpha+p*(1-alpha-beta)* and *g = n*p + m - i)*.

Typical values of (alpha,beta) are:

    - (0,1)    : *p(k) = k/n* : linear interpolation of cdf (R, type 4)
    - (.5,.5)  : *p(k) = (k+1/2.)/n* : piecewise linear function (R, type 5)
    - (0,0)    : *p(k) = k/(n+1)* : (R type 6)
    - (1,1)    : *p(k) = (k-1)/(n-1)*. In this case, p(k) = mode[F(x[k])].
      That's R default (R type 7)
    - (1/3,1/3): *p(k) = (k-1/3)/(n+1/3)*. Then p(k) ~ median[F(x[k])].
      The resulting quantile estimates are approximately median-unbiased
      regardless of the distribution of x. (R type 8)
    - (3/8,3/8): *p(k) = (k-3/8)/(n+1/4)*. Blom.
      The resulting quantile estimates are approximately unbiased
      if x is normally distributed (R type 9)
    - (.4,.4)  : approximately quantile unbiased (Cunnane)
    - (.35,.35): APL, used with PWM

Parameters
----------
    x : sequence
        Input data, as a sequence or array of dimension at most 2.
    prob : sequence
        List of quantiles to compute.
    alpha : {0.4, float} optional
        Plotting positions parameter.
    beta : {0.4, float} optional
        Plotting positions parameter.
    axis : {None, int} optional
        Axis along which to perform the trimming.
        If None, the input array is first flattened.
    limit : tuple
        Tuple of (lower, upper) values. Values of a outside this closed interval
        are ignored.
    c         S   sÿ   t  i |  i ƒ  ƒ } t | ƒ } | d j o) t i t  i t | ƒ d t ƒd t ƒS| d j o# t i t  i	 | | i
 ƒ d t ƒS| | | } t  i | i d | d ƒ ƒ i t ƒ } | | i d d ƒ } d | | | d i ƒ  | | | i ƒ  S(   Ni    RY   RZ   i   g      ð?(   Ra   R	  Rq   R[   RK   R`   Rb   Rc   Rd   t   resizeR•   RI   R9  t   clipRö   RÝ   t   tolist(   R„   Rn   t   pR   Rk   t   alephRm   t   gamma(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   _quantiles1DY  s    )#(Rp   i    i   RÛ   g      ð?i   s   Array should be 2D at most !N(   RK   R`   RŒ   RH   R‹   Rd   Ra   RJ   R^   Rt  R–   (
   R„   R¸   t   alphapt   betapRO   t   limitR¨  R’   R¥  Rn   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   0  s    )	c         C   sc   | d j  p | d j o t  d | ƒ ‚ n t |  d | d g d | d | d | d d ƒi ƒ  S(	   s­   Calculate the score at the given 'per' percentile of the
    sequence a.  For example, the score at per=50 is the median.

    This function is a shortcut to mquantile

    i    g      Y@s7   The percentile should be between 0. and 100. ! (got %s)R¸   R©  Rª  R«  RO   (   RU   R   R"  (   R„   t   perR«  R©  Rª  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR#   t  s
    "c         C   s   t  i |  d t ƒi d d ƒ }  |  i ƒ  } t i |  i d t ƒ} d | | )t i	 d | d ƒ | | d | | | |  i
 ƒ  |  <t  i | d |  i ƒS(   sÊ  Returns the plotting positions (or empirical percentile points) for the
    data.
    Plotting positions are defined as (i-alpha)/(n-alpha-beta), where:
        - i is the rank order statistics
        - n is the number of unmasked values along the given axis
        - alpha and beta are two parameters.

    Typical values for alpha and beta are:
        - (0,1)    : *p(k) = k/n* : linear interpolation of cdf (R, type 4)
        - (.5,.5)  : *p(k) = (k-1/2.)/n* : piecewise linear function (R, type 5)
        - (0,0)    : *p(k) = k/(n+1)* : Weibull (R type 6)
        - (1,1)    : *p(k) = (k-1)/(n-1)*. In this case, p(k) = mode[F(x[k])].
          That's R default (R type 7)
        - (1/3,1/3): *p(k) = (k-1/3)/(n+1/3)*. Then p(k) ~ median[F(x[k])].
          The resulting quantile estimates are approximately median-unbiased
          regardless of the distribution of x. (R type 8)
        - (3/8,3/8): *p(k) = (k-3/8)/(n+1/4)*. Blom.
          The resulting quantile estimates are approximately unbiased
          if x is normally distributed (R type 9)
        - (.4,.4)  : approximately quantile unbiased (Cunnane)
        - (.35,.35): APL, used with PWM

Parameters
----------
    x : sequence
        Input data, as a sequence or array of dimension at most 2.
    prob : sequence
        List of quantiles to compute.
    alpha : {0.4, float} optional
        Plotting positions parameter.
    beta : {0.4, float} optional
        Plotting positions parameter.

    Rp   i   iÿÿÿÿRY   i    RZ   (   RK   R`   RŒ   R”   Rˆ   Ra   Rb   RT   Rc   RŠ   R‰   R  (   R„   R  t   betaRk   t   plpos(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   ‚  s    #!
8c          G   sÐ   t  |  Œ  i } | i d d d d ƒ } | i d ƒ } | i d ƒ i t ƒ } | | 8} | d C} | | d | 9} | d | | d 8} | | d | d	 :} t i | | i d ƒ ƒ p t	 d
 ƒ ‚ n | S(   sh  
Computes a transform on input data (any number of columns).  Used to
test for homogeneity of variance prior to running one-way stats.  Each
array in *args is one level of a factor.  If an F_oneway() run on the
transformed data and found significant, variances are unequal.   From
Maxwell and Delaney, p.112.

Returns: transformed data for use in an ANOVA
    RO   i    R  i   i   g      ø?g      à?g      ð?g       @s'   Lack of convergence in obrientransform.(
   R    R8  R@   R   Rˆ   Rö   Rc   RK   t   allcloseRU   (   Ri   R„   Ro   Rn   Rk   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   ²  s    


c         C   sA   t  i |  d t ƒ}  |  i | ƒ } |  i | d d ƒ} | | S(   s[  Calculates the signal-to-noise ratio, as the ratio of the mean over
    standard deviation along the given axis.

    Parameters
    ----------
        data : sequence
            Input data
        axis : {0, int} optional
            Axis along which to compute. If None, the computation is performed
            on a flat version of the array.
Rp   R  i    (   RK   R`   RŒ   R   R%   (   R„   RO   Rn   Rz  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR'   Ë  s    c         C   s   t  i |  ƒ i d | d d ƒ S(   sa  Returns a biased estimate of the variance of the data, as the average
    of the squared deviations from the mean.

    Parameters
    ----------
        data : sequence
            Input data
        axis : {0, int} optional
            Axis along which to compute. If None, the computation is performed
            on a flat version of the array.
    RO   R  i    (   RK   R]   R@   (   R„   RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR"   Ý  s    c         C   s   t  i |  ƒ i d | d d ƒ S(   sÀ  Returns a biased estimate of the standard deviation of the data, as the
    square root of the average squared deviations from the mean.

    Parameters
    ----------
        data : sequence
            Input data
        axis : {0,int} optional
            Axis along which to compute. If None, the computation is performed
            on a flat version of the array.

    Notes
    -----
        samplestd(a) is equivalent to a.std(ddof=0)

    RO   R  i    (   RK   R]   R%   (   R„   RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR!   ì  s    c         C   s   t  i |  ƒ i d | d d ƒ S(   NRO   R  i   (   RK   R]   R@   (   RN   RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR@      s    c         C   s   t  i |  ƒ i d | d d ƒ S(   NRO   R  i   (   RK   R]   R%   (   RN   RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR%     s    c         C   sD   t  |  | ƒ \ }  } |  i d | d d ƒ t i |  i d | ƒ ƒ S(   NRO   R  i   (   RQ   R%   RK   R¬   Rˆ   (   RN   RO   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR+     s    c         C   sT   t  |  | ƒ \ }  } |  i d | ƒ } |  i d | d d ƒ t i | d ƒ } | S(   NRO   R  i    i   (   RQ   Rˆ   R%   RK   R¬   (   RN   RO   Rk   Rƒ  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR$     s    )c         C   s<   t  i |  ƒ }  | |  i d  ƒ |  i d d  d d ƒ } | S(   NRO   R  i   (   RK   R]   R   RJ   R%   (   RN   t   scoreRC   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyRC     s    )c         C   sE   t  i |  ƒ }  |  i d d ƒ } |  i d d d d ƒ } |  | | S(   NRO   i    R  (   RK   R]   R   R%   (   RN   R3  R  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyRE     s    c         C   sU   t  i |  ƒ t  i | ƒ }  } | i d | ƒ } | i d d d d ƒ } |  | | S(   NRO   i    R  (   RK   R]   R   R%   (   t   scorest   compareRO   t   mnst   sstd(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyRD   !  s    c          G   sã   t  |  Œ  } t | ƒ } | i ƒ  } | d i ƒ  | i ƒ  d t | ƒ } | i d ƒ | i d ƒ | i ƒ  d i ƒ  } | | } | d } | | } | t | ƒ }	 | t | ƒ }
 |	 |
 } t i | | | ƒ } | | f S(   s	  
Performs a 1-way ANOVA, returning an F-value and probability given
any number of groups.  From Heiman, pp.394-7.

Usage:   f_oneway (*args)    where *args is 2 or more arrays, one per
                                  treatment group
Returns: f-value, probability
i   iÿÿÿÿi   (   R    R[   Rˆ   Ry   Rc   R   R  t   fprob(   Ri   R„   t   ngroupsR6  t   sstott   ssbgt   sswgt   dfbgt   dfwgt   msbt   mswt   fR¸   (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   .  s    
(0



c   
      C   sA  t  i |  d t d d ƒ}  t  i | d t d d ƒ} t  i |  ƒ i ƒ  p t  i | ƒ i ƒ  o t d ƒ ‚ n t i i | ƒ t i i |  ƒ } t  i	 | d d | d d d | d d | d d d ƒ } t  i
 | d ƒ } d | d | | d | d } | d | | | d | d | d d }	 | |	 S(	   sc   Calculation of Wilks lambda F-statistic for multivarite data, per
    Maxwell & Delaney p.657.
    Rp   RÛ   i   s1   Not implemented when the inputs have missing datai   i   g      ð?g      à?(   RK   R`   RŒ   Rx   R„  t   NotImplementedErrorRa   t   linalgt   detR¬   R‹   (
   t   ERt   EFt   dfnumt   dfdenRN   RR   t   lmbdat   qt   n_umt   d_en(    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR   G  s    ,"C".c          G   sÄ  t  |  Œ  i t ƒ } t | ƒ } | d j  o t d | d ƒ ‚ n t i t | d d ƒd ƒ } | i t	 j	 o4 t i
 | ƒ } | i ƒ  i | d ƒ i t ƒ } n
 | i } | i \ } } t i g  } | i D] } | t | ƒ qÔ ~ d t ƒ} | | i ƒ  i d d ƒ d	 d	 … d f i t ƒ } d
 | d | i ƒ  t | | d | ƒ }	 t i | i d ƒ | | d
 d d ƒ }
 |
 d | | | d
 d |	 } | t i | | d
 ƒ f S(   sü  Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA.
    This function calculates the Friedman Chi-square test for repeated measures
    and returns the result, along with the associated probability value.

    Each input is considered a given group. Ideally, the number of treatments
    among each group should be equal. If this is not the case, only the first
    n treatments are taken into account, where n is the number of treatments
    of the smallest group.
    If a group has some missing values, the corresponding treatments are masked
    in the other groups.
    The test statistic is corrected for ties.

    Masked values in one group are propagated to the other groups.

    Returns: chi-square statistic, associated p-value
    i   s   Less than 3 groups (%i): s%   the Friedman test is NOT appropriate.RO   i    iÿÿÿÿRY   i   Ni   g       @g      (@g      ð?(   R    Rö   Rc   R[   RU   RK   t   masked_valuesR    R  RI   t	   mask_colsRq   R”   R—   RF   Rh   R•   Ra   R`   R8  R   t   objectRE  RÝ   Ry   R  R)  (   Ri   R„   Rm   t   rankedRk   Rl   R  R   R…   t   tie_correctionR¸  R,  (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyR	   Y  s"    
%	95.,"(   gš™™™™™¹?gš™™™™™¹?(   i   i   (   gš™™™™™¹?gš™™™™™¹?(   i   i   (   gš™™™™™¹?gš™™™™™¹?(   i   i   (   gš™™™™™¹?gš™™™™™¹?(   i   i   (    (    (j   t   __doc__t
   __author__t   __docformat__t   __all__t   numpyRa   RF   t   numpy.maRK   RG   RH   RI   R}   R”  R  t   scipy.specialR¦   t
   scipy.miscR:  Rr   t   genmissingvaldocRQ   RS   RX   R    R   RŒ   R   RJ   R    R
   R   R   R   R   R   t   corrcoefR   Rd   R*   R   R   R   R   R,   R&   R<   R;   R=   R>   R   R   R   R   t
   kolmogorovRH  R<  R   R   RO  R-   R4   R5   Ro  R1   R2   R3   t   trim1R6   R9   R7   R8   R/   R?   R0   R.   R:   RB   R   RA   R(   R   R   R“  R)   R   R   RŸ   R   R#   R   R   R   R'   R"   R!   R@   R%   R+   R$   RC   RE   RD   R   R   R	   (    (    (    sH   P:\graphics\Tools\Python26\lib\site-packages\scipy\stats\mstats_basic.pyt   <module>   s<  									*4					<LK	A		%<		
*			-	!&Y
 			GLC*					