
Mc           @   sz   d  d k  l Z l Z l Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d S(   i(   t   logt   expt   floorc         C   s   d d d d d d g } t  |   d } | d } d } d	 } | | d
 t |  8} x0 t d  D]" } | d 7} | | | | 7} qc W| t d |  S(   NgSvS@g+WUg8@g뒦~4gM&S?g1!e[־g      ?g      @i    g      ?i   g%@(   t   floatR    t   range(   t   Zt   coft   xt   tempt   sert   j(    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   gammaln%   s    
 
c         C   s   d d d d d d d d g } d	 } t  |   d
 } x0 t d  D]" } | d
 7} | | | | 7} qA Wt |  d t  |   t  |   d t t  |   d  } | S(   Ng
ö)$@g&Ԏgta@gQfg>@~)@gA~g~\>giE>g?g      ?i   g*hS@g      ?g      @(   R   R   R    (   R   R   R	   R   R
   t   result(    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   gammaln25   s     
<c         C   s   t  t t |    d  S(   Ni   (   t   roundR   R   (   R   (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   gammaE   s    c         C   s   t  t t |    d  S(   Ni   (   R   R   R   (   R   (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   gamma2I   s    c         C   s   d } d d d d d g } |  d j  o
 d GHd S|  d	 j o t  |  d
  Sx7 | |  j  o) | } | d
 7} | i | | |  qQ W| |  Sd  S(   Ni   g      ?g       @g      @g      8@i    s5   error: factorial only works for non-negative integersii    i   (   R   t   append(   t   Nt   ntopt   arrR
   (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt	   factorialM   s     
c         C   s;   |  d j  o
 d GHd S|  d j o d St  |  d  Sd  S(   Ni    s5   error: factorial only works for non-negative integersii   g        g      ?(   R   (   R   (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   factln^   s    c         C   s"   t  |   t  |  t  |  |  S(   N(   R   (   t   nt   k(    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   bicolnh   s    c         C   s   t  d t t |  |    S(   Ng      ?(   R   R   R   (   R   R   (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   bicol   s    c         C   s(   t  t |   t |  t |  |   S(   N(   R   R   (   t   zt   w(    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   betap   s    c         C   se   t  |   }  t  |  } t  |  } t  |  } t t | |  t |  | | |  t |  |   S(   s   hyperGeometric(N, r, n, x):
                N   is population size
                r   is the number in the population identified as a success
                n   is the sample size
                x   is the number in the sample identified as a success
    (   R   R   R   (   R   t   rR   R   (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   hyperGeometrict   s
    N(   t   mathR    R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sK   /woldlab/castor/data00/home/georgi/erange-4.0a/cistematic/cisstat/helper.pyt   <module>#   s   						
			