
    M/Ph                     2    d Z ddlZddlZ	 	 ddZ	 	 ddZdS )zC
Initialization methods for states of exponential smoothing models
    NFc                    t          |           }d }d }||s8| d         }|dk    r| d         | d         z
  }n|dk    r| d         | d         z  }n|d|z  k     rt          d          t          j        | d |                   }|}|Gt	          j        |                               |          |d|z           |z                                  }|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	            t/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/tsa/exponential_smoothing/initialization.py_initialization_simpler   	   sC    u::DM xaE>>!!HuQx/MMe^^!!HuQx/M !&&&& = > > > &7'7&7 899Yu--22155aAg>BHHJJMu$RaRy=8$RaRy=8-)999    c           	          |                                  } 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                     }|
                    |d                                          }	|dz  d	k    r:|	                    d
          
                    d                                          }	|dk    r||	z
  }
n|dk    r||	z  }
t          j        ||z            t          j        z  }|
j        |d t          |
          <   t          j        |                    ||          j        d          }|dk    r|t          j        |          z  }n|dk    r|t          j        |          z  }|	                                j        } t          j        t          j        d          t          j        d          dz   f         }| j        dk    rt          j        |           j        } t          j        t          j                            |                              | 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"    JJLLEu::Dbyy * + + 	+  1.!&&&& = > > > q,122'>> , - - - q$"2233 xRWW7G-G%H%H!I!IJJ 5!="2X"=!=>??'7EEJJLLa1$$)//33;;A>>CCEEM u.II.I hx"2233bf<(/OS^^O:KK"2335A? ? ? u(8 9 99(8 9 99 $$&&- 5bimma//0DzQe$$&:binnT**..uSbSz::;;DGMM~~Q	%DGd1g---)999r   )FFN)__doc__numpyr   pandasr   r   r@    r   r   <module>rE      ss             9>,0 :  :  :  :F <A/3L: L: L: L: L: L:r   