
    'YHh                     0    d Z ddlZddlZ	 	 ddZ	 	 ddZy)zC
Initialization methods for states of exponential smoothing models
    Nc                    t        |       }d }d }||s'| d   }|dk(  r| d   | d   z
  }n|dk(  r| d   | d   z  }n|d|z  k  rt        d      t        j                  | d |       }|}|;t	        j
                  |       j                  |      |d|z   |z  j                         }|dk(  r	| d | |z
  }n|dk(  r| d | |z  }|||fS )Nr   add   mul   lCannot compute initial seasonals using heuristic method with less than two full seasonal cycles in the data.)len
ValueErrornpmeanpdSeriesdiff)	endogtrendseasonalseasonal_periodsnobsinitial_trendinitial_seasonalinitial_levelms	            m/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/tsa/exponential_smoothing/initialization.py_initialization_simpler   	   s    u:DM xaE>!!HuQx/Me^!!HuQx/M !&&& = > > &7'7 89YYu-2215aA>BHHJMu$Ray=8$Ray=8-)999    c           	         | j                         } t        |       }|dk  rt        d      d }|r|d|z  k  rt        d      dd|dz  z  z   }||k  rt        d      t        d||z        }t	        |t        t        j                  ||z                    }t        j                  | d ||z         }|j                  |d      j                         }	|dz  d	k(  r.|	j                  d
      j                  d      j                         }	|dk(  r||	z
  }
n
|dk(  r||	z  }
t        j                  ||z        t        j                  z  }
j                  |d t        |
       t        j                   |j#                  ||      j$                  d      }|dk(  r|t        j                  |      z  }n|dk(  r|t        j                  |      z  }|	j'                         j                  } t        j(                  t        j*                  d      t        j,                  d      dz   f   }| j.                  dk(  rt        j0                  |       j$                  } t        j2                  t        j4                  j7                  |      j9                  | d d             }|d	   }d }	|dk(  r|d   }	n|dk(  rd|d   |d	   z  z   }	||	|fS )N
   z;Cannot use heuristic method with less than 10 observations.r   r   z~Cannot use heuristic method to compute initial seasonal and levels with less than 10 + 2 * (seasonal_periods // 2) datapoints.   T)centerr   r   r   r   )axis)copyr	   r
   minmaxintr   ceilr   r   rollingr   shiftzerosnanvaluesnanmeanreshapeTdropnac_onesarangendim
atleast_2dsqueezelinalgpinvdot)r   r   r   r   r   r   min_obsk_cyclesseriesr   	detrendedtmpexogbetar   s                  r   _initialization_heuristicr@   ,   s    JJLEu:Dby * + 	+ !&&& = > > q,122'> , - - q$"223 xRWWW7G-G%H!IJ 5!="2X"=>?'7EJJLa1$)//3;;A>CCEM u.I.I hhx"223bff<(//OS^::KK"2355A? u(8 99(8 99 $$&-- 55biima//0DzzQe$&&::biinnT*..uSbz:;DGMM~Q	%DGd1g---)999r   )FFN)__doc__numpyr   pandasr   r   r@    r   r   <module>rE      s/      9>,0 :F <A/3L:r   