mņ
6 DDc           @   s   d  k  Td   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z	 d
   Z
 d   Z d   Z d   Z d f  d     YZ d S(   (   t   *c         C   s   |  d S(   Ni    (   t   x(   R   (    (    t(   /home/lathuili/fractal/double_lin_reg.pyt   first   s    c         C   s   |  d S(   Ni   (   R   (   R   (    (    R   t   second
   s    c         C   s   |  | S(   N(   R   t   y(   R   R   (    (    R   t   add   s    c         C   s   |  |  S(   N(   R   (   R   (    (    R   t   square   s    c         C   s   t  |   t |   S(   N(   R   R   R   (   R   (    (    R   t   xiyi   s    c         C   s   t  |   } | | S(   N(   R   R   t   a(   R   R	   (    (    R   t	   xi_square   s    c         C   s   t  t t t |    S(   N(   t   reduceR   t   mapR
   R   (   R   (    (    R   t   sum_xi_square    s    c         C   s   t  t t t |    S(   N(   R   R   R   R   R   (   R   (    (    R   t   sum_xiyi%   s    c         C   s   t  t t t |    S(   N(   R   R   R   R   R   (   R   (    (    R   t   sum_xi)   s    c         C   s   t  t t t |    S(   N(   R   R   R   R   R   (   R   (    (    R   t   sum_yi-   s    c         C   s¶   |  d d |  d d |  d d |  d d } | d j oj | d |  d d |  d d | d | } | d |  d d |  d d | d | } | | f Sn
 t d  d  S(   Ni    i   t   solve_linear2_2(   t   At   dett   bR   R   t   NonInversibleSystem(   R   R   R   R   R   (    (    R   R   8   s    2..c   	      C   ss   t  |   } t |   } | } | } t |   } t	 |   } t |   } t | | f | | f f | | f  } | S(   N(   R   t   Nuaget   Sum_xiR   t   a11t   a21t   a12t   lent   a22R   t   b1R   t   b2R   t   coeff(	   R   R   R   R   R   R   R   R   R   (    (    R   t   lin_regD   s    'c            s"     d   } t t t | |    S(   Nc            s*   t  t |     d t |     d  S(   Ni    i   (   R   R   R   t   coefficientR   (   R   (   R!   (    R   t   ecart_carreV   s    (   R"   R   R   R   R   (   R   R!   R"   (    (   R!   R   t   moindre_carreU   s    t   Double_Linear_Regressionc           B   s)   t  Z d  Z d   Z d   Z d   Z RS(   s1   Module to approximate a plot by the two best linec         C   s   | |  _ |  i   d  S(   N(   t   plott   selft   Plott   double_lin_reg(   R&   R%   (    (    R   t   __init___   s    	c         C   sĖ   d } xµ t d t |  i  d  D] } t |  i d | ! } t |  i | t |  i  ! } t	 |  i d | !|  t	 |  i | t |  i  !|  } | | j  o | | f } | } q# q# W| |  _ d  S(   Nt   infinityi   i    (   t   mint   rangeR   R&   R'   t   iR    t   coefficient1t   coefficient2R#   t   ecartR!   t   Coefficient(   R&   R!   R0   R+   R-   R.   R/   (    (    R   R(   e   s     9c         C   s   |  i S(   N(   R&   R1   (   R&   (    (    R   R!   q   s    (   t   __name__t
   __module__t   __doc__R)   R(   R!   (    (    (    R   R$   \   s    		N(   t   my_exceptionsR   R   R   R   R   R
   R   R   R   R   R   R    R#   R$   (   R   R   R#   R
   R   R   R   R   R   R   R$   R   R    R   (    (    R   t   ?   s   													
