ó
¬™xTc           @   s~   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d „  Z d „  Z	 d „  Z
 d „  Z e d	 k rz e ƒ  n  d
 S(   iÿÿÿÿ(   t   division(   t   scaling(   t   flex(   t   approx_equalc       	   C   s¾  t  j t d ƒ ƒ d }  t  j t d ƒ ƒ d } d  } t  j t d ƒ ƒ d d } t  j t g d ƒ } xt d ƒ D]} | d } d | | } t  j | g d ƒ } t  j | g d ƒ }	 t j |  | | | | | |	 ƒ }
 |
 j	 ƒ  } |
 j
 ƒ  } |
 j ƒ  } |
 j ƒ  } xi t | | | | ƒ D]R \ } } } } d | d k sQt ‚ | d k r)t | | d	 d
 ƒs{t ‚ q)q)Wqx Wx4t d d ƒ D]#} | d } d | | } t  j | g d ƒ } t  j | g d ƒ }	 t j |  | | | | | |	 ƒ }
 |
 j	 ƒ  } |
 j
 ƒ  } |
 j ƒ  } |
 j ƒ  } x„ t | |	 | | | | ƒ D]g \ } } } } } } d | d k syt ‚ | d k rK| d k r²t | | d	 d
 ƒs¯t ‚ q²qKqKWq“Wd  S(   Niè  g     Àr@i    g      ð?i2   g      I@g      ð¿gÍÌÌÌÌÌì?t   epsgš™™™™™¹?i   (   R   t   doublet   ranget   Nonet   boolt   Falset   xrangeR   t   likelihood_ratio_outlier_testt	   mean_fobst   std_fobst   posterior_modet   posterior_mode_snd_dert   zipt   AssertionErrorR   (   t   fobst   fcalct   sigmast   epsilont   centrict   iit   at   bt   alphat   betat
   tmp_objectt   meant   stdt   modet   sdmot   mmt   mt   vt   fc(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/tst_outlier.pyt   tst_outliers_compare_mode_mean   s`    
	(&
	4c          C   s  t  j d g d ƒ }  t  j t d ƒ ƒ d d } t  j d g d ƒ } t  j d g d ƒ } t  j t g d ƒ } t  j d g d ƒ } t  j d g d ƒ } t j |  | | | | | | ƒ } | j ƒ  } x< t | | ƒ D]+ \ }	 }
 t	 |	 |
 d d d ƒsÞ t
 ‚ qÞ Wt  j d g d ƒ }  t  j t d ƒ ƒ d d } t  j d g d ƒ } t  j d g d ƒ } t  j t g d ƒ } t  j d g d ƒ } t  j d	 g d ƒ } t j |  | | | | | | ƒ } | j ƒ  } x< t | | ƒ D]+ \ }	 }
 t	 |
 |	 d	 d d
 ƒsët
 ‚ qëWd  S(   Ni   i
   i    i   g®Gáz®ï?R   gš™™™™™©?id   gòÒMbX¹?gü©ñÒMbP?(   R   R   R   R   R	   R   R   R   R   R   R   t   True(   R   R   R   R   R   R   R   R   R   t   fR"   (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/tst_outlier.pyt    tst_outliers_find_posterior_mode>   sH    	#	c          C   sa  t  j t d ƒ ƒ d }  t  j d g d ƒ } t  j d g d ƒ } t  j d g d ƒ } t  j t g d ƒ } t  j d g d ƒ } t  j d g d ƒ } t j |  | | | | | | ƒ } | j ƒ  } | j ƒ  }	 | j	 ƒ  }
 d } | j
 d | ƒ } x_ t | |	 | |
 |  ƒ D]E \ } } } } } | | | d k  rL| sYt ‚ q| st ‚ qWd  S(   Niè  iÈ   i   i    g®Gáz®ï?g      @g       @(   R   R   R   R   R	   R   R   t   log_likelihoodt   posterior_mode_log_likelihoodR   t   flag_potential_outliersR   R   (   R   R   R   R   R   R   R   R   t   cur_likt   pm_likR   t   levelt   flagst   flt   plt   lR"   t   fo(    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/tst_outlier.pyt   tst_loglikelihoodsh   s0    	.c           C   s   t  ƒ  t ƒ  t ƒ  d GHd  S(   Nt   OK(   R%   R(   R4   (    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/tst_outlier.pyt   runƒ   s    t   __main__N(   t
   __future__R    t   mmtbxR   t   cctbx.array_familyR   t   libtbx.test_utilsR   R%   R(   R4   R6   t   __name__(    (    (    sG   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/tst_outlier.pyt   <module>   s   	7	*		