Ë
    £�Dj€h  ã                   óª   — d dl Zd dlZd dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZmZ  G d„ d	e«      Z G d
„ de«      Z eee«       y)é    N)Ú
inv_boxcox)ÚboxcoxÚrv_continuousÚrv_discrete)Ú	rv_frozen)Ú
PandasData)ÚResults)ÚResultsWrapperÚpopulate_wrapperÚunion_dictsc                   ó–  ‡ — e Zd ZdZ	 dˆ fd„	Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
e
j                  d„ «       Z
ed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zej                  d„ «       Zdd„Zdd„Zd„ Z	 	 	 	 	 dd„Zˆ xZS )ÚHoltWintersResultsa«  
    Results from fitting Exponential Smoothing models.

    Parameters
    ----------
    model : ExponentialSmoothing instance
        The fitted model instance.
    params : dict
        All the parameters for the Exponential Smoothing model.
    sse : float
        The sum of squared errors.
    aic : float
        The Akaike information criterion.
    aicc : float
        AIC with a correction for finite sample sizes.
    bic : float
        The Bayesian information criterion.
    optimized : bool
        Flag indicating whether the model parameters were optimized to fit
        the data.
    level : ndarray
        An array of the levels values that make up the fitted values.
    trend : ndarray
        An array of the trend values that make up the fitted values.
    season : ndarray
        An array of the seasonal values that make up the fitted values.
    params_formatted : pd.DataFrame
        DataFrame containing all parameters, their short names and a flag
        indicating whether the parameter's value was optimized to fit the data.
    resid : ndarray
        An array of the residuals of the fittedvalues and actual values.
    k : int
        The k parameter used to remove the bias in AIC, BIC etc.
    fittedvalues : ndarray
        An array of the fitted values. Fitted by the Exponential Smoothing
        model.
    fittedfcast : ndarray
        An array of both the fitted values and forecast values.
    fcastvalues : ndarray
        An array of the forecast values forecast by the Exponential Smoothing
        model.
    mle_retvals : {None, scipy.optimize.optimize.OptimizeResult}
        Optimization results if the parameters were optimized to fit the data.
    c                 ó(  •— |j                   | _         t        ‰| �	  ||«       || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        || _        || _        || _        || _        || _        || _        y ©N)ÚdataÚsuperÚ__init__Ú_modelÚ_sseÚ_aicÚ_aiccÚ_bicÚ
_optimizedÚ_levelÚ_trendÚ_seasonÚ_params_formattedÚ_fittedvaluesÚ_fittedfcastÚ_fcastvaluesÚ_residÚ_kÚ_mle_retvals)ÚselfÚmodelÚparamsÚsseÚaicÚaiccÚbicÚ	optimizedÚlevelÚtrendÚseasonÚparams_formattedÚresidÚkÚfittedvaluesÚfittedfcastÚfcastvaluesÚmle_retvalsÚ	__class__s                     €úgC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels\tsa\holtwinters\results.pyr   zHoltWintersResults.__init__B   s”   ø€ ð( —J‘JˆŒ	Ü‰Ñ˜ Ô'ØˆŒØˆŒ	ØˆŒ	ØˆŒ
ØˆŒ	Ø#ˆŒØˆŒØˆŒØˆŒØ!1ˆÔØ)ˆÔØ'ˆÔØ'ˆÔØˆŒØˆŒØ'ˆÕó    c                 ó   — | j                   S )z3
        The Akaike information criterion.
        )r   ©r$   s    r7   r(   zHoltWintersResults.aici   ó   € ð
 �y‰yÐr8   c                 ó   — | j                   S )z@
        AIC with a correction for finite sample sizes.
        )r   r:   s    r7   r)   zHoltWintersResults.aiccp   s   € ð
 �z‰zÐr8   c                 ó   — | j                   S )z5
        The Bayesian information criterion.
        )r   r:   s    r7   r*   zHoltWintersResults.bicw   r;   r8   c                 ó   — | j                   S )zS
        The sum of squared errors between the data and the fittted value.
        )r   r:   s    r7   r'   zHoltWintersResults.sse~   r;   r8   c                 ó   — | j                   S )zA
        The model used to produce the results instance.
        ©r   r:   s    r7   r%   zHoltWintersResults.model…   ó   € ð
 �{‰{Ðr8   c                 ó   — || _         y r   r@   ©r$   Úvalues     r7   r%   zHoltWintersResults.modelŒ   s	   € àˆ�r8   c                 ó   — | j                   S )zO
        An array of the levels values that make up the fitted values.
        )r   r:   s    r7   r,   zHoltWintersResults.level�   rA   r8   c                 ó   — | j                   S )zU
        Flag indicating if model parameters were optimized to fit the data.
        )r   r:   s    r7   r+   zHoltWintersResults.optimized—   s   € ð
 �‰Ðr8   c                 ó   — | j                   S )zN
        An array of the trend values that make up the fitted values.
        )r   r:   s    r7   r-   zHoltWintersResults.trendž   rA   r8   c                 ó   — | j                   S )zQ
        An array of the seasonal values that make up the fitted values.
        )r   r:   s    r7   r.   zHoltWintersResults.season¥   s   € ð
 �|‰|Ðr8   c                 ó   — | j                   S )z®
        DataFrame containing all parameters

        Contains short names and a flag indicating whether the parameter's
        value was optimized to fit the data.
        )r   r:   s    r7   r/   z#HoltWintersResults.params_formatted¬   s   € ð ×%Ñ%Ð%r8   c                 ó   — | j                   S )z/
        An array of the fitted values
        )r   r:   s    r7   r2   zHoltWintersResults.fittedvalues¶   s   € ð
 ×!Ñ!Ð!r8   c                 ó   — | j                   S )zI
        An array of both the fitted values and forecast values.
        )r   r:   s    r7   r3   zHoltWintersResults.fittedfcast½   ó   € ð
 × Ñ Ð r8   c                 ó   — | j                   S )z1
        An array of the forecast values
        )r    r:   s    r7   r4   zHoltWintersResults.fcastvaluesÄ   rL   r8   c                 ó   — | j                   S )zR
        An array of the residuals of the fittedvalues and actual values.
        )r!   r:   s    r7   r0   zHoltWintersResults.residË   rA   r8   c                 ó   — | j                   S )zJ
        The k parameter used to remove the bias in AIC, BIC etc.
        )r"   r:   s    r7   r1   zHoltWintersResults.kÒ   s   € ð
 �w‰wˆr8   c                 ó   — | j                   S )zX
        Optimization results if the parameters were optimized to fit the data.
        ©r#   r:   s    r7   r5   zHoltWintersResults.mle_retvalsÙ   rL   r8   c                 ó   — || _         y r   rQ   rC   s     r7   r5   zHoltWintersResults.mle_retvalsà   s
   € à!ˆÕr8   c                 óP   — | j                   j                  | j                  ||«      S )a£  
        In-sample prediction and out-of-sample forecasting

        Parameters
        ----------
        start : int, str, or datetime, optional
            Zero-indexed observation number at which to start forecasting, ie.,
            the first forecast is start. Can also be a date string to
            parse or a datetime type. Default is the the zeroth observation.
        end : int, str, or datetime, optional
            Zero-indexed observation number at which to end forecasting, ie.,
            the first forecast is start. Can also be a date string to
            parse or a datetime type. However, if the dates index does not
            have a fixed frequency, end must be an integer index if you
            want out of sample prediction. Default is the last observation in
            the sample.

        Returns
        -------
        forecast : ndarray
            Array of out of sample forecasts.
        )r%   Úpredictr&   )r$   ÚstartÚends      r7   rT   zHoltWintersResults.predictä   s!   € ð. �z‰z×!Ñ! $§+¡+¨u°cÓ:Ð:r8   c                 ó‚  — 	 t        | j                  j                  dd«      }t        |t        «      szt        | j                  j                  t
        j                  t
        j                  f«      r<| j                  j                  d   |z   }| j                  j                  d   ||z  z   }n+| j                  j                  j                  d   }||z   dz
  }| j                  j                  | j                  ||¬«      S # t        $ r5  | j                  j                  dd|i| j                  ¤Žj                  cY S w xY w)a'  
        Out-of-sample forecasts

        Parameters
        ----------
        steps : int
            The number of out of sample forecasts from the end of the
            sample.

        Returns
        -------
        forecast : ndarray
            Array of out of sample forecasts
        Úfreqé   éÿÿÿÿr   )rU   rV   Úh© )Úgetattrr%   Ú_indexÚ
isinstanceÚintÚpdÚDatetimeIndexÚPeriodIndexÚshaperT   r&   ÚAttributeErrorÚ_predictr4   )r$   ÚstepsrX   rU   rV   s        r7   ÚforecastzHoltWintersResults.forecastý   s	  € ð	KÜ˜4Ÿ:™:×,Ñ,¨f°aÓ8ˆDÜ˜d¤CÔ(¬ZØ—
‘
×!Ñ!¤B×$4Ñ$4´b·n±nÐ#Eô.ð Ÿ
™
×)Ñ)¨"Ñ-°Ñ4�Ø—j‘j×'Ñ'¨Ñ+¨e°d©lÑ:‘àŸ
™
×)Ñ)×/Ñ/°Ñ2�Ø˜e‘m aÑ'�Ø—:‘:×%Ñ% d§k¡k¸ÀCÐ%ÓHÐHøÜò 	Kà&�4—:‘:×&Ñ&Ñ>¨Ð>°$·+±+Ñ>×JÑJÒJð	Kús   ‚C=D  Ä ;D>Ä=D>c                 ó"  — ddl m} ddlm} | j                  }|j
                  j                  dz   }d}| j                  j                  j                  }t        |t        j                  «      r|j                  d   }n&t        |t        j                  «      r|j                  }| j                  j                  €dn| j                  j                   }ddddd	d
œ}| j"                  d   }	|	rdnd}
t        |	t$        «      r|	n| j"                  d   }t        |t&        «      r|d›}d|gfd|j
                  j                  gfdt%        t)        j*                  | j,                  «      «      gfd|| j                  j.                     gfd|| j                  j                     gfdt%        |«      gfdt%        |
«      gfdt%        |«      gfg}dt%        t1        | j                  j2                  «      «      gfd| j4                  d›gfd| j6                  d›gfd| j8                  d›gfd| j:                  d›gfddg} |«       }|j=                  | |||¬ «       | j>                  }d!„ }g }|jA                  «       D ]\  \  }}|jC                   ||jD                  d"   «      |jD                  d   d#›t%        tG        |jD                  d$   «      «      d#›g«       Œ^  ||g d%¢d&tI        |jJ                  «      ¬'«      }|jL                  jC                  |«       |S )(a6  
        Summarize the fitted Model

        Returns
        -------
        smry : Summary instance
            This holds the summary table and text, which can be printed or
            converted to various output formats.

        See Also
        --------
        statsmodels.iolib.summary.Summary
        r   )ÚSummary)ÚSimpleTablez Model ResultsÚendogNÚAdditiveÚMultiplicativeÚNone)ÚaddÚadditiveÚmulÚmultiplicativeNÚ
use_boxcoxTFÚlamdaz>10.5fzDep. Variable:zModel:z
Optimized:zTrend:z	Seasonal:zSeasonal Periods:zBox-Cox:zBox-Cox Coeff.:zNo. Observations:ÚSSEz5.3fÚAICÚBICÚAICC)zDate:N)zTime:N)ÚgleftÚgrightÚtitlec                 ó"  — t        j                  | «      }d}t        j                  | «      rt        | «      d›S |dk7  rt	        t        j
                  |«      «      }|dkD  s|dk  r| d›S t        d|z
  d«      }d|› d	�}|j                  | «      S )
NrY   ú>20r   é   éýÿÿÿz>20.5gé   z{:>20.zf})ÚnpÚabsÚisnanÚstrr`   Úlog10ÚminÚformat)ÚxÚabs_xÚscaleÚdecÚfmts        r7   Ú_fmtz(HoltWintersResults.summary.<locals>._fmtc  s‰   € Ü—F‘F˜1“IˆEØˆEÜ�x‰x˜Œ{Ü˜a›& ˜Ð&Ø˜ŠzÜœBŸH™H U›OÓ,�Ø�qŠy˜E BšJØ˜F˜Ð$Ü�a˜%‘i Ó#ˆCØ˜C˜5 Ð$ˆCØ—:‘:˜a“=Ð r8   rY   r~   é   )ÚcoeffÚcoder+   Ú )Úheadersr|   Ústubs)'Ústatsmodels.iolib.summaryrj   Ústatsmodels.iolib.tablerk   r%   r6   Ú__name__r   Ú
orig_endogr_   ra   Ú	DataFrameÚcolumnsÚSeriesÚnameÚseasonalÚseasonal_periodsr&   r…   Úfloatr‚   Úanyr+   r-   Úlenrl   r'   r(   r*   r)   Úadd_table_2colsr/   ÚiterrowsÚappendÚilocÚboolÚlistÚindexÚtables)r$   rj   rk   r%   r|   Údep_variabler˜   rž   ÚlookupÚ	transformÚbox_cox_transformÚbox_cox_coeffÚtop_leftÚ	top_rightÚsmryÚ	formattedrŽ   ÚtabÚ_ÚvalsÚparams_tables                        r7   ÚsummaryzHoltWintersResults.summary  s  € õ 	6Ý7à—
‘
ˆØ—‘×(Ñ(Ð+;Ñ;ˆàˆØ—Z‘Z—_‘_×/Ñ/ˆ
Ü�j¤"§,¡,Ô/Ø%×-Ñ-¨aÑ0‰LÜ˜
¤B§I¡IÔ.Ø%Ÿ?™?ˆLð �z‰z×"Ñ"Ð*ñ à—‘×,Ñ,ð 	ð Ø"Ø#Ø.Øñ
ˆð —K‘K Ñ-ˆ	Ù$-™D°5Ðä# I¬sÔ3‰I¸¿¹ÀWÑ9Mð 	ô �m¤UÔ+Ø,¨VÐ4ˆMà ˜~Ð.Ø˜Ÿ™×0Ñ0Ð1Ð2ØœC¤§¡ t§~¡~Ó 6Ó7Ð8Ð9Ø˜˜tŸz™z×/Ñ/Ñ0Ð1Ð2Ø˜6 $§*¡*×"5Ñ"5Ñ6Ð7Ð8Ø ¤3Ð'7Ó#8Ð"9Ð:Øœ#Ð/Ó0Ð1Ð2Ø¤ ]Ó!3Ð 4Ð5ð	
ˆð !¤3¤s¨4¯:©:×+;Ñ+;Ó'<Ó#=Ð">Ð?Ø˜Ÿ™ �Ð(Ð)Ø˜Ÿ™ �Ð(Ð)Ø˜Ÿ™ �Ð(Ð)Ø˜Ÿ™ 4Ð(Ð*Ð+ØØð
ˆ	ñ ‹yˆØ×ÑØ˜¨¸%ð 	ô 	
ð ×)Ñ)ˆ	ò	!ð ˆØ ×)Ñ)Ó+ò 	‰GˆAˆtØ�J‰Já˜Ÿ™ 1™Ó&Ø—y‘y ‘| CÐ(Üœ4 §	¡	¨!¡Ó-Ó.¨sÐ3ðõð	ñ #ØÚ2ØÜ�y—‘Ó'ô	
ˆð 	�‰×Ñ˜<Ô(àˆr8   c                 óî  — |dv rdddœ|   }|dvrt        d«      ‚|�|dk(  r| j                  j                  }nC|dk(  rd	}n;| j                  j                  |«      \  }}}t	        |t
        «      r|j                  }|d	k  r|| j                  j                  z  }|| j                  j                  kD  rt        d
«      ‚| j                  j                  }	| j                  j                  }
| j                  j                  }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }t        | j                  j                  d«      }dd| j                  j                  z  z   |dz   | j                  j                  z  z   |
z   }|dk(  }|	dk(  }|dk(  }|r#t        j                   }t        j"                  }d}n"t        j$                  }t        j                   }d	}|rt        j                   }d}nt        j$                  }d	}| j&                  }| j                  }| j(                  }t        j*                  ||f«      }t        j*                  |dz   |f«      } t        j*                  |dz   |f«      }!t        j*                  ||z   |f«      }"|d	k(  r-| j                  d   | ddd…f<   | j                  d   |!ddd…f<   n||dz
     | ddd…f<   ||dz
     |!ddd…f<   d	|k  r^||k  rY| j                  d   }#t        j,                  |#|d |d| f«      }$t        j.                  |$|df«      j0                  |"| d…dd…f<   n2t        j.                  |||z
  | |df«      j0                  |"| d…dd…f<   |	€||!dd…dd…f<   d}d	}|€||"dd…dd…f<   d	}|
sd}|rt3        | j4                  |«      }%n| j4                  }%|dk(  r| j                  j6                  |%z
  }&n| j                  j6                  |%z
  |%z  }&t        j8                  t        j:                  |&dz  «      t=        |&«      |z
  z  «      }'t	        |t        j>                  «      r |j@                  ||fk7  rt        d«      ‚|}(�nI|dk(  r&t        jB                  jE                  |&||fd¬«      }(�n|€°|€$t        jB                  jG                  ||«      |'z  }(nöt	        |tH        «      r5t        jB                  jK                  |«      })|)jG                  ||«      |'z  }(n±t	        |t        jB                  jJ                  «      r|jG                  ||«      |'z  }(nwt        d«      ‚t	        |tL        tN        f«      r&|jQ                  |&«      }* |jR                  |*d||fiŽ}(n0t	        |tT        «      r|jS                  ||f¬«      }(nt        d«      ‚tW        |«      D �]  }+ ||!|+dz
  dd…f   |«      }, || |+dz
  dd…f   |,«      }-|"|+|z
  dd…f   }. ||-|.«      }/|dk(  r(d}0|rd|.z  nd}1|r|1| |+dz
  dd…f   z  n|1}2|rd|-z  nd}3n.|/}0|rd	n|.}1|r|1| |+dz
  dd…f   z  n|1| |+dz
  dd…f   z   }2|rd	n|-}3|/|0|(|+dd…f   z  z   ||+dd…f<   |-|||-z  |1z   z  |(|+dd…f   z  z   | |+dd…f<   |,|||,z  |2z   z  |(|+dd…f   z  z   |!|+dd…f<   |.|||.z  |3z   z  |(|+dd…f   z  z   |"|+dd…f<   �Œ |rtY        ||«      }t        jZ                  t        j\                  |«      «      }4|j@                  d	   dk(  r|j^                  dkD  r	|4ddd…f   }4t	        | j                  j`                  tb        «      s|4S | j                  je                  |||z   dz
  «      \  }}}}5|dk(  r.tg        jh                  |4|5| j                  jj                  ¬«      }4|4S tg        jl                  |4|5¬ «      }4|4S )!a“  
        Random simulations using the state space formulation.

        Parameters
        ----------
        nsimulations : int
            The number of simulation steps.
        anchor : int, str, or datetime, optional
            First period for simulation. The simulation will be conditional on
            all existing datapoints prior to the `anchor`.  Type depends on the
            index of the given `endog` in the model. Two special cases are the
            strings 'start' and 'end'. `start` refers to beginning the
            simulation at the first period of the sample, and `end` refers to
            beginning the simulation at the first period after the sample.
            Integer values can run from 0 to `nobs`, or can be negative to
            apply negative indexing. Finally, if a date/time index was provided
            to the model, then this argument can be a date string to parse or a
            datetime type. Default is 'end'.
        repetitions : int, optional
            Number of simulated paths to generate. Default is 1 simulated path.
        error : {"add", "mul", "additive", "multiplicative"}, optional
            Error model for state space formulation. Default is ``"add"``.
        random_errors : optional
            Specifies how the random errors should be obtained. Can be one of
            the following:

            * ``None``: Random normally distributed values with variance
              estimated from the fit errors drawn from numpy's standard
              RNG (can be seeded with the `random_state` argument). This is the
              default option.
            * A distribution function from ``scipy.stats``, e.g.
              ``scipy.stats.norm``: Fits the distribution function to the fit
              errors and draws from the fitted distribution.
              Note the difference between ``scipy.stats.norm`` and
              ``scipy.stats.norm()``, the latter one is a frozen distribution
              function.
            * A frozen distribution function from ``scipy.stats``, e.g.
              ``scipy.stats.norm(scale=2)``: Draws from the frozen distribution
              function.
            * A ``np.ndarray`` with shape (`nsimulations`, `repetitions`): Uses
              the given values as random errors.
            * ``"bootstrap"``: Samples the random errors from the fit errors.

        random_state : int or np.random.RandomState, optional
            A seed for the random number generator or a
            ``np.random.RandomState`` object. Only used if `random_errors` is
            ``None``. Default is ``None``.

        Returns
        -------
        sim : pd.Series, pd.DataFrame or np.ndarray
            An ``np.ndarray``, ``pd.Series``, or ``pd.DataFrame`` of simulated
            values.
            If the original data was a ``pd.Series`` or ``pd.DataFrame``, `sim`
            will be a ``pd.Series`` if `repetitions` is 1, and a
            ``pd.DataFrame`` of shape (`nsimulations`, `repetitions`) else.
            Otherwise, if `repetitions` is 1, a ``np.ndarray`` of shape
            (`nsimulations`,) is returned, and if `repetitions` is not 1 a
            ``np.ndarray`` of shape (`nsimulations`, `repetitions`) is
            returned.

        Notes
        -----
        The simulation is based on the state space model of the Holt-Winter's
        methods. The state space model assumes that the true value at time
        :math:`t` is randomly distributed around the prediction value.
        If using the additive error model, this means:

        .. math::

            y_t &= \hat{y}_{t|t-1} + e_t\\
            e_t &\sim \mathcal{N}(0, \sigma^2)

        Using the multiplicative error model:

        .. math::

            y_t &= \hat{y}_{t|t-1} \cdot (1 + e_t)\\
            e_t &\sim \mathcal{N}(0, \sigma^2)

        Inserting these equations into the smoothing equation formulation leads
        to the state space equations. The notation used here follows
        [1]_.

        Additionally,

        .. math::

           B_t &= b_{t-1} \circ_d \phi\\
           L_t &= l_{t-1} \circ_b B_t\\
           S_t &= s_{t-m}\\
           Y_t &= L_t \circ_s S_t,

        where :math:`\circ_d` is the operation linking trend and damping
        parameter (multiplication if the trend is additive, power if the trend
        is multiplicative), :math:`\circ_b` is the operation linking level and
        trend (addition if the trend is additive, multiplication if the trend
        is multiplicative), and :math:`\circ_s` is the operation linking
        seasonality to the rest.

        The state space equations can then be formulated as

        .. math::

           y_t &= Y_t + \eta \cdot e_t\\
           l_t &= L_t + \alpha \cdot (M_e \cdot L_t + \kappa_l) \cdot e_t\\
           b_t &= B_t + \beta \cdot (M_e \cdot B_t + \kappa_b) \cdot e_t\\
           s_t &= S_t + \gamma \cdot (M_e \cdot S_t + \kappa_s) \cdot e_t\\

        with

        .. math::

           \eta &= \begin{cases}
                       Y_t\quad\text{if error is multiplicative}\\
                       1\quad\text{else}
                   \end{cases}\\
           M_e &= \begin{cases}
                       1\quad\text{if error is multiplicative}\\
                       0\quad\text{else}
                   \end{cases}\\

        and, when using the additive error model,

        .. math::

           \kappa_l &= \begin{cases}
                       \frac{1}{S_t}\quad
                       \text{if seasonality is multiplicative}\\
                       1\quad\text{else}
                   \end{cases}\\
           \kappa_b &= \begin{cases}
                       \frac{\kappa_l}{l_{t-1}}\quad
                       \text{if trend is multiplicative}\\
                       \kappa_l\quad\text{else}
                   \end{cases}\\
           \kappa_s &= \begin{cases}
                       \frac{1}{L_t}\quad\text{if seasonality is
                                               multiplicative}\\
                       1\quad\text{else}
                   \end{cases}

        When using the multiplicative error model

        .. math::

           \kappa_l &= \begin{cases}
                       0\quad
                       \text{if seasonality is multiplicative}\\
                       S_t\quad\text{else}
                   \end{cases}\\
           \kappa_b &= \begin{cases}
                       \frac{\kappa_l}{l_{t-1}}\quad
                       \text{if trend is multiplicative}\\
                       \kappa_l + l_{t-1}\quad\text{else}
                   \end{cases}\\
           \kappa_s &= \begin{cases}
                       0\quad\text{if seasonality is multiplicative}\\
                       L_t\quad\text{else}
                   \end{cases}

        References
        ----------
        .. [1] Hyndman, R.J., & Athanasopoulos, G. (2018) *Forecasting:
           principles and practice*, 2nd edition, OTexts: Melbourne,
           Australia. OTexts.com/fpp2. Accessed on February 28th 2020.
        )rq   rs   rp   rr   )rp   rr   zerror must be 'add' or 'mul'!NrV   rU   r   z/Cannot anchor simulation outside of the sample.rt   ru   Úsmoothing_levelÚsmoothing_trendÚsmoothing_seasonalÚdamping_trendrY   r�   Úinitial_levelrZ   Úinitial_trendÚinitial_seasonszNIf random_errors is an ndarray, it must have shape (nsimulations, repetitions)Ú	bootstrapT)ÚsizeÚreplacezWArgument random_state must be None, an integer, or an instance of np.random.RandomStaterÁ   )rÁ   z,Argument random_errors has unexpected value!)r¨   rœ   )r¨   )7Ú
ValueErrorr%   ÚnobsÚ_get_index_locr_   ÚslicerU   r-   Údamped_trendr�   r&   Úmaxrž   Ú	has_trendÚhas_seasonalr‚   ÚmultiplyÚpowerrp   r,   r.   ÚemptyÚconcatenateÚtileÚTr   r2   Ú_yÚsqrtÚsumr¡   Úndarrayrd   ÚrandomÚchoiceÚrandnr`   ÚRandomStater   r   ÚfitÚrvsr   Úranger   Ú
atleast_1dÚsqueezerÁ   r   r   Ú_get_prediction_indexra   r›   Úendog_namesr™   )6r$   ÚnsimulationsÚanchorÚrepetitionsÚerrorÚrandom_errorsÚrandom_stateÚ	start_idxr´   r-   Údampedr�   rt   ru   ÚalphaÚbetaÚgammaÚphiÚmÚn_paramsÚmul_seasonalÚ	mul_trendÚ	mul_errorÚop_bÚop_dÚ	neutral_bÚop_sÚ	neutral_sr,   r   r.   ÚyÚlvlÚbÚsr¿   Ú_sÚfittedr0   ÚsigmaÚepsÚrngr&   ÚtÚb0Úl0Ús0Úy0ÚetaÚkappa_lÚkappa_bÚkappa_sÚsimr¨   s6                                                         r7   ÚsimulatezHoltWintersResults.simulate„  s  € ðd Ð2Ñ2Ø!&¸%Ñ@ÀÑGˆEØ˜Ñ&ÜÐ<Ó=Ð=ð ˆ>˜V uš_ØŸ
™
Ÿ™‰IØ�wÒØ‰Ià"Ÿj™j×7Ñ7¸Ó?‰OˆI�q˜!Ü˜)¤UÔ+Ø%ŸO™O�	Ø�qŠ=Ø˜Ÿ™Ÿ™Ñ(ˆIØ�t—z‘z—‘Ò&ÜÐNÓOÐOð —
‘
× Ñ ˆØ—‘×(Ñ(ˆØ—:‘:×&Ñ&ˆØ—[‘[ Ñ.ˆ
Ø—‘˜GÑ$ˆØ—‘Ð-Ñ.ˆØ�{‰{Ð,Ñ-ˆØ—‘Ð0Ñ1ˆØ�k‰k˜/Ñ*ˆä�—
‘
×+Ñ+¨QÓ/ˆàØ�$—*‘*×&Ñ&Ñ&ñ'à�1‰u˜Ÿ
™
×/Ñ/Ñ/ñ0ð ñð 	ð   5Ñ(ˆØ˜U‘Nˆ	Ø˜U‘Nˆ	ñ Ü—;‘;ˆDÜ—8‘8ˆDØ‰Iä—6‘6ˆDÜ—;‘;ˆDØˆIÙÜ—;‘;ˆDØ‰Iä—6‘6ˆDØˆIð —
‘
ˆØ—‘ˆØ—‘ˆä�H‰H�l KÐ0Ó1ˆä�h‰h˜ qÑ(¨+Ð6Ó7ˆÜ�H‰H�l QÑ&¨Ð4Ó5ˆÜ�H‰H�l QÑ&¨Ð4Ó5ˆà˜Š>ØŸ™ _Ñ5ˆC�’A�‰JØ—{‘{ ?Ñ3ˆAˆb’!ˆeŠHà˜y¨1™}Ñ-ˆC�’A�‰JØ˜i¨!™mÑ,ˆAˆb’!ˆe‰HØ�	Š>˜i¨1šnØ"Ÿk™kÐ*;Ñ<ˆOÜ—‘Ø   Ð,¨f°Z°iÐ.@ÐAóˆBô Ÿ™  [°!Ð$4Ó5×7Ñ7ˆAˆqˆb‰c’1ˆfŠIäŸ™Ø�y 1‘} yÐ1°KÀÐ3Cóç‰að ˆqˆb‰c’1ˆf‰Ið
 ˆ=ØˆAŠa’ˆd‰GØˆCØˆDØÐØˆAŠa’ˆd‰GØˆEÙØˆCñ Ü˜D×-Ñ-¨uÓ5‰Fà×&Ñ&ˆFØ�EŠ>Ø—J‘J—M‘M FÑ*‰Eà—Z‘Z—]‘] VÑ+¨vÑ5ˆEÜ—‘œŸ™˜u a™xÓ(¬C°«J¸Ñ,AÑBÓCˆô �m¤R§Z¡ZÔ0Ø×"Ñ" |°[Ð&AÒAÜ ð2óð ð  ŠCØ˜kÒ)Ü—)‘)×"Ñ"Ø˜\¨;Ð7Àð #ó ŠCð Ð"ØÐ#Ü—i‘i—o‘o l°KÓ@À5ÑH‘Ü˜L¬#Ô.Ü—i‘i×+Ñ+¨LÓ9�Ø—i‘i ¨kÓ:¸UÑB‘Ü˜L¬"¯)©)×*?Ñ*?Ô@Ø"×(Ñ(¨°{ÓCÀeÑK‘ä ð>óð ô ˜¬´{Ð'CÔDØ"×&Ñ& uÓ-ˆFØ#�-×#Ñ# VÐN°<ÀÐ2MÑN‰CÜ˜¤yÔ1Ø×#Ñ#¨,¸Ð)DÐ#ÓE‰CäÐKÓLÐLä�|Ó$ó 	JˆAÙ�a˜˜A™šq˜‘k 3Ó'ˆBÙ�c˜!˜a™%¢˜(‘m RÓ(ˆBØ�1�q‘5š!�8‘ˆBÙ�b˜"“ˆBØ˜Š~Ø�Ù$0˜!˜bš&°a�Ù5>˜' C¨¨A©ªq¨¡MÒ1ÀG�Ù$0˜!˜bš&°a‘à�Ù+™!°�ñ !ð ˜c ! a¡%ª (™mÒ+à  3 q¨1¡uªa x¡=Ñ0ð ñ
  ,™!°�à˜3  Qª T¡™?Ñ*ˆAˆa’ˆd‰GØ˜U i°"¡n°wÑ&>Ñ?À#ÀaÊÀdÁ)ÑKÑKˆC�’1�‰IØ˜4 9¨r¡>°GÑ#;Ñ<¸sÀ1ÂaÀ4¹yÑHÑHˆAˆa’ˆd‰GØ˜5 I°¡N°WÑ$<Ñ=ÀÀAÂqÀDÁ	ÑIÑIˆAˆa’ˆd‹Gð/	Jñ2 Ü˜1˜eÓ$ˆAä�m‰mœBŸJ™J q›MÓ*ˆØ�7‰7�1‰:˜Š?˜qŸv™v¨šzØ�dšA�g‘,ˆCä˜$Ÿ*™*Ÿ/™/¬:Ô6ØˆJàŸ™×9Ñ9Ø�y <Ñ/°!Ñ3ó
‰ˆˆ1ˆa�ð ˜!ÒÜ—)‘)˜C u°4·:±:×3IÑ3IÔJˆCð ˆ
ô —,‘,˜s¨%Ô0ˆCàˆ
r8   r   )NN)rY   )NrY   rp   NN)r—   Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr(   r)   r*   r'   r%   Úsetterr,   r+   r-   r.   r/   r2   r3   r4   r0   r1   r5   rT   rh   r·   r	  Ú__classcell__)r6   s   @r7   r   r      s¯  ø„ ñ+ð~ õ%%(ðN ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ‡\�\ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñ&ó ð&ð ñ"ó ð"ð ñ!ó ð!ð ñ!ó ð!ð ñó ðð ñó ðð ñ!ó ð!ð ×Ññ"ó ð"ó;ó2Kò<gðX ØØØØ÷ir8   r   c                   ót   — e Zd ZdddddddœZ eej                  e«      ZdddœZ eej                  e«      Zy)ÚHoltWintersResultsWrapperÚrows)r2   r,   r0   r.   r-   ÚslopeÚdates)rT   rh   N)	r—   r
  r  Ú_attrsr   r
   Ú_wrap_attrsÚ_methodsÚ_wrap_methodsr\   r8   r7   r  r  ð  sK   „ àØØØØØñ€Fñ ˜n×8Ñ8¸&ÓA€KØ"°Ñ8€HÙ × <Ñ <¸hÓG�Mr8   r  )Únumpyr‚   Úpandasra   Úscipy.specialr   Úscipy.statsr   r   r   Úscipy.stats.distributionsr   Ústatsmodels.base.datar   Ústatsmodels.base.modelr	   Ústatsmodels.base.wrapperr
   r   r   r   r  r\   r8   r7   ú<module>r!     sX   ðÛ Û Ý $÷ñ õ
 0å ,Ý *÷ñ ôY˜ô YôxH ô Hñ Ð*Ð,>Õ ?r8   