ó
    Ñ]j"›  ã                  óú  • S SK Jr  S SKrS SKJr  S SKJrJr  S SKr	S SK
Jr  S SKJs  Js  Jr  S SKJr  S SKJrJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SK J!r!J"r"J#r#  S SK$J%r%J&r&  S SK'J(r(  S SK)J*r*J+r+  S SK,J-r-J.r.  S SK/J0r0J1r1  \(       a  S SK2J3r3J4r4J5r5  S SK6J7r7J8r8  S SK9J:r:            SS jr;      S S jr<\" S5       " S S\05      5       r=\" S5       " S S\1\=5      5       r> " S S\=5      r?g)!é    )ÚannotationsN)Úpartial)ÚTYPE_CHECKINGÚcast)Ú	Timedelta)Ú
set_module)Úis_datetime64_dtypeÚis_numeric_dtype)ÚDatetimeTZDtype)Ú	ABCSeries)Úisna)Úcommon)Údtype_to_unit)ÚBaseIndexerÚExponentialMovingWindowIndexerÚGroupbyIndexer)Úget_jit_argumentsÚmaybe_use_numba)Úzsqrt)Úgenerate_numba_ewm_funcÚgenerate_numba_ewm_table_func)ÚEWMMeanStateÚgenerate_online_numba_ewma_func)Ú
BaseWindowÚBaseWindowGroupby)ÚTimedeltaConvertibleTypesÚTimeUnitÚnpt)Ú	DataFrameÚSeries)ÚNDFramec                óÂ  • [         R                  " XX#5      nUS:”  a  [        S5      eU b  U S:  a  [        S5      eO˜Ub  US:  a  [        S5      eUS-
  S-  n O{UbJ  US::  a  [        S5      eS[        R                  " [        R
                  " S5      U-  5      -
  nSU-  S-
  n O.Ub   US::  d  US:”  a  [        S	5      eSU-
  U-  n O[        S
5      e[        U 5      $ )Né   z8comass, span, halflife, and alpha are mutually exclusiver   z comass must satisfy: comass >= 0zspan must satisfy: span >= 1é   z#halflife must satisfy: halflife > 0g      à?z"alpha must satisfy: 0 < alpha <= 1z1Must pass one of comass, span, halflife, or alpha)r   Úcount_not_noneÚ
ValueErrorÚnpÚexpÚlogÚfloat)ÚcomassÚspanÚhalflifeÚalphaÚvalid_countÚdecays         ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pandas/core/window/ewm.pyÚget_center_of_massr2   ?   sø   € ô ×'Ò'¨°hÓF€KØ�QƒÜÐSÓTÐTð ÑØ�A‹:ÜÐ?Ó@Ð@ð à	Ñ	Ø�!‹8ÜÐ;Ó<Ð<Ø˜‘(˜a‘‰Ø	Ñ	Ø�q‹=ÜÐBÓCÐCØ”B—F’Fœ2Ÿ6š6 #›;¨Ñ1Ó2Ñ2ˆØ�U‘˜Q‘‰Ø	Ñ	Ø�A‹:˜ ›ÜÐAÓBÐBØ�e‘)˜uÑ$‰äÐLÓMÐMä�‹=Ðó    c                ó’  • [        U R                  5      n[        SU5      n[        U [        5      (       a  U R
                  n [        R                  " U R                  [        R                  5      [        R                  S9n[        [        U5      R                  U5      R                  5      n[        R                  " U5      U-  $ )a­  
Return the diff of the times divided by the half-life. These values are used in
the calculation of the ewm mean.

Parameters
----------
times : np.ndarray, Series
    Times corresponding to the observations. Must be monotonically increasing
    and ``datetime64[ns]`` dtype.
halflife : float, str, timedelta, optional
    Half-life specifying the decay

Returns
-------
np.ndarray
    Diff of the times divided by the half-life
r   ©Údtype)r   r6   r   Ú
isinstancer   Ú_valuesr'   ÚasarrayÚviewÚint64Úfloat64r*   r   Úas_unitÚ_valueÚdiff)Útimesr-   ÚunitÚ_timesÚ	_halflifes        r1   Ú_calculate_deltasrD   `   sˆ   € ô* ˜Ÿ™Ó%€DÜ�
˜DÓ!€DÜ�%œ×#Ñ#Ø—‘ˆÜ�ZŠZ˜Ÿ
™
¤2§8¡8Ó,´B·J±JÑ?€FÜ”i Ó)×1Ñ1°$Ó7×>Ñ>Ó?€IÜ�7Š7�6‹?˜YÑ&Ð&r3   zpandas.api.typingc                  óX  ^ • \ rS rSrSr/ SQr         SSS.                     SU 4S jjjjr        SS jrSS jr S   SS	 jjr	SU 4S
 jjr
\
r   S SS jjr   S SS jjrSSS jjrSSS jjr    S       SS jjr   S     S S jjrSrU =r$ )!ÚExponentialMovingWindowé~   aÄ  
Provide exponentially weighted (EW) calculations.

Exactly one of ``com``, ``span``, ``halflife``, or ``alpha`` must be
provided if ``times`` is not provided. If ``times`` is provided and ``adjust=True``,
``halflife`` and one of ``com``, ``span`` or ``alpha`` may be provided.
If ``times`` is provided and ``adjust=False``, ``halflife`` must be the only
provided decay-specification parameter.

Parameters
----------
com : float, optional
    Specify decay in terms of center of mass

    :math:`\alpha = 1 / (1 + com)`, for :math:`com \geq 0`.

span : float, optional
    Specify decay in terms of span

    :math:`\alpha = 2 / (span + 1)`, for :math:`span \geq 1`.

halflife : float, str, timedelta, optional
    Specify decay in terms of half-life

    :math:`\alpha = 1 - \exp\left(-\ln(2) / halflife\right)`, for
    :math:`halflife > 0`.

    If ``times`` is specified, a timedelta convertible unit over which an
    observation decays to half its value. Only applicable to ``mean()``,
    and halflife value will not apply to the other functions.

alpha : float, optional
    Specify smoothing factor :math:`\alpha` directly

    :math:`0 < \alpha \leq 1`.

min_periods : int, default 0
    Minimum number of observations in window required to have a value;
    otherwise, result is ``np.nan``.

adjust : bool, default True
    Divide by decaying adjustment factor in beginning periods to account
    for imbalance in relative weightings (viewing EWMA as a moving average).

    - When ``adjust=True`` (default), the EW function is calculated using weights
      :math:`w_i = (1 - \alpha)^i`. For example, the EW moving average of the series
      [:math:`x_0, x_1, ..., x_t`] would be:

    .. math::
        y_t = \frac{x_t + (1 - \alpha)x_{t-1} + (1 - \alpha)^2 x_{t-2} + ... + (1 -
        \alpha)^t x_0}{1 + (1 - \alpha) + (1 - \alpha)^2 + ... + (1 - \alpha)^t}

    - When ``adjust=False``, the exponentially weighted function is calculated
      recursively:

    .. math::
        \begin{split}
            y_0 &= x_0\\
            y_t &= (1 - \alpha) y_{t-1} + \alpha x_t,
        \end{split}
ignore_na : bool, default False
    Ignore missing values when calculating weights.

    - When ``ignore_na=False`` (default), weights are based on absolute positions.
      For example, the weights of :math:`x_0` and :math:`x_2` used in calculating
      the final weighted average of [:math:`x_0`, None, :math:`x_2`] are
      :math:`(1-\alpha)^2` and :math:`1` if ``adjust=True``, and
      :math:`(1-\alpha)^2` and :math:`\alpha` if ``adjust=False``.

    - When ``ignore_na=True``, weights are based
      on relative positions. For example, the weights of :math:`x_0` and :math:`x_2`
      used in calculating the final weighted average of
      [:math:`x_0`, None, :math:`x_2`] are :math:`1-\alpha` and :math:`1` if
      ``adjust=True``, and :math:`1-\alpha` and :math:`\alpha` if ``adjust=False``.

times : np.ndarray, Series, default None

    Only applicable to ``mean()``.

    Times corresponding to the observations. Must be monotonically increasing and
    ``datetime64[ns]`` dtype.

    If 1-D array like, a sequence with the same shape as the observations.

method : str {'single', 'table'}, default 'single'
    Execute the rolling operation per single column or row (``'single'``)
    or over the entire object (``'table'``).

    This argument is only implemented when specifying ``engine='numba'``
    in the method call.

    Only applicable to ``mean()``

Returns
-------
pandas.api.typing.ExponentialMovingWindow
    An instance of ExponentialMovingWindow for further exponentially weighted (EW)
    calculations, e.g. using the ``mean`` method.

See Also
--------
rolling : Provides rolling window calculations.
expanding : Provides expanding transformations.

Notes
-----
See :ref:`Windowing Operations <window.exponentially_weighted>`
for further usage details and examples.

Examples
--------
>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
>>> df
     B
0  0.0
1  1.0
2  2.0
3  NaN
4  4.0

>>> df.ewm(com=0.5).mean()
          B
0  0.000000
1  0.750000
2  1.615385
3  1.615385
4  3.670213
>>> df.ewm(alpha=2 / 3).mean()
          B
0  0.000000
1  0.750000
2  1.615385
3  1.615385
4  3.670213

**adjust**

>>> df.ewm(com=0.5, adjust=True).mean()
          B
0  0.000000
1  0.750000
2  1.615385
3  1.615385
4  3.670213
>>> df.ewm(com=0.5, adjust=False).mean()
          B
0  0.000000
1  0.666667
2  1.555556
3  1.555556
4  3.650794

**ignore_na**

>>> df.ewm(com=0.5, ignore_na=True).mean()
          B
0  0.000000
1  0.750000
2  1.615385
3  1.615385
4  3.225000
>>> df.ewm(com=0.5, ignore_na=False).mean()
          B
0  0.000000
1  0.750000
2  1.615385
3  1.615385
4  3.670213

**times**

Exponentially weighted mean with weights calculated with a timedelta ``halflife``
relative to ``times``.

>>> times = ['2020-01-01', '2020-01-03', '2020-01-10', '2020-01-15', '2020-01-17']
>>> df.ewm(halflife='4 days', times=pd.DatetimeIndex(times)).mean()
          B
0  0.000000
1  0.585786
2  1.523889
3  1.523889
4  3.233686
)	Úcomr,   r-   r.   Úmin_periodsÚadjustÚ	ignore_nar@   ÚmethodN©Ú	selectionc          
     óÐ  >• [         TU ]  UUc  SO[        [        U5      S5      S SS U
US9  X l        X0l        X@l        XPl        Xpl        X€l	        X�l
        U R                  Gb¥  [        U R                  SS 5      n[        U5      (       d   [        U[        5      (       d  [        S5      e[!        U R                  5      [!        U5      :w  a  [        S5      e[        U R                  ["        [$        R&                  [(        R*                  45      (       d  [        S5      e[-        U R                  5      R/                  5       (       a  [        S5      e[1        U R                  U R                  5      U l        [4        R6                  " U R                  U R
                  U R                  5      S	:”  aN  U R                  (       d  [9        S
5      e[;        U R                  U R
                  S U R                  5      U l        g SU l        g U R                  bI  [        U R                  ["        [$        R&                  [(        R*                  45      (       a  [        S5      e[(        R>                  " [        U R@                  RB                  S	   S-
  S	5      [(        RD                  S9U l        [;        U R                  U R
                  U R                  U R                  5      U l        g )Nr#   F)ÚobjrI   ÚonÚcenterÚclosedrL   rN   r6   ztimes must be datetime64 dtype.z,times must be the same length as the object.z/halflife must be a timedelta convertible objectz$Cannot convert NaT values to integerr   zRNone of com, span, or alpha can be specified if times is provided and adjust=Falseg      ð?zKhalflife can only be a timedelta convertible argument if times is not None.r5   )#ÚsuperÚ__init__ÚmaxÚintrH   r,   r-   r.   rJ   rK   r@   Úgetattrr	   r7   r   r&   ÚlenÚstrÚdatetimeÚ	timedeltar'   Útimedelta64r   ÚanyrD   Ú_deltasr   r%   ÚNotImplementedErrorr2   Ú_comÚonesrP   Úshaper<   )ÚselfrP   rH   r,   r-   r.   rI   rJ   rK   r@   rL   rN   Útimes_dtypeÚ	__class__s                €r1   rU   Ú ExponentialMovingWindow.__init__D  s0  ø€ ô 	‰ÑØØ(Ñ0™´c¼#¸kÓ:JÈAÓ6NØØØØØð 	ñ 	
ð ŒØŒ	Ø ŒØŒ
ØŒØ"ŒØŒ
Ø�:‰:Ò!Ü! $§*¡*¨g°tÓ<ˆKä# K×0Ñ0Ü˜k¬?×;Ñ;ä Ð!BÓCÐCÜ�4—:‘:‹¤# c£(Ó*Ü Ð!OÓPÐPÜ˜dŸm™m¬c´8×3EÑ3EÄrÇ~Á~Ð-V×WÑWÜ Ð!RÓSÐSÜ�D—J‘JÓ×#Ñ#×%Ñ%Ü Ð!GÓHÐHÜ,¨T¯Z©Z¸¿¹ÓGˆDŒLô ×$Ò$ T§X¡X¨t¯y©y¸$¿*¹*ÓEÈÓIØ—{—{Ü-ð=óð ô /¨t¯x©x¸¿¹ÀDÈ$Ï*É*ÓU�•	à�•	à�}‰}Ñ(¬ZØ—‘¤¤X×%7Ñ%7¼¿¹ÐH÷.ñ .ô !ð)óð ô
 Ÿ7š7¤3 t§x¡x§~¡~°aÑ'8¸1Ñ'<¸aÓ#@ÌÏ
É
ÑSˆDŒLÜ*ð —‘Ø—	‘	Ø—‘Ø—
‘
óˆD�Ir3   c                ó   • g ©N© )rd   ÚstartÚendÚnum_valss       r1   Ú_check_window_boundsÚ,ExponentialMovingWindow._check_window_bounds�  s   € ð
 	r3   c                ó   • [        5       $ )zK
Return an indexer class that will compute the window start and end bounds
)r   ©rd   s    r1   Ú_get_window_indexerÚ+ExponentialMovingWindow._get_window_indexer—  s   € ô .Ó/Ð/r3   c                óò   • [        U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  UUU R                  S9$ )a÷  
Return an ``OnlineExponentialMovingWindow`` object to calculate
exponentially moving window aggregations in an online method.

Parameters
----------
engine: str, default ``'numba'``
    Execution engine to calculate online aggregations.
    Applies to all supported aggregation methods.

engine_kwargs : dict, default None
    Applies to all supported aggregation methods.

    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{'nopython': True, 'nogil': False, 'parallel': False}`` and will be
      applied to the function

Returns
-------
OnlineExponentialMovingWindow
)rP   rH   r,   r-   r.   rI   rJ   rK   r@   ÚengineÚengine_kwargsrN   )ÚOnlineExponentialMovingWindowrP   rH   r,   r-   r.   rI   rJ   rK   r@   Ú
_selection)rd   ru   rv   s      r1   ÚonlineÚExponentialMovingWindow.online�  s_   € ô4 -Ø—‘Ø—‘Ø—‘Ø—]‘]Ø—*‘*Ø×(Ñ(Ø—;‘;Ø—n‘nØ—*‘*ØØ'Ø—o‘oñ
ð 	
r3   c                ó,   >• [         TU ]  " U/UQ70 UD6$ )a«  
Aggregate using one or more operations over the specified axis.

Parameters
----------
func : function, str, list or dict
    Function to use for aggregating the data. If a function, must either
    work when passed a Series/Dataframe or when passed to
    Series/Dataframe.apply.

    Accepted combinations are:

    - function
    - string function name
    - list of functions and/or function names, e.g. ``[np.sum, 'mean']``
    - dict of axis labels -> functions, function names or list of such.
*args
    Positional arguments to pass to `func`.
**kwargs
    Keyword arguments to pass to `func`.

Returns
-------
scalar, Series or DataFrame

    The return can be:

    * scalar : when Series.agg is called with single function
    * Series : when DataFrame.agg is called with a single function
    * DataFrame : when DataFrame.agg is called with several functions

See Also
--------
pandas.DataFrame.rolling.aggregate

Notes
-----
The aggregation operations are always performed over an axis, either the
index (default) or the column axis. This behavior is different from
`numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`,
`var`), where the default is to compute the aggregation of the flattened
array, e.g., ``numpy.mean(arr_2d)`` as opposed to
``numpy.mean(arr_2d, axis=0)``.

`agg` is an alias for `aggregate`. Use the alias.

Functions that mutate the passed object can produce unexpected
behavior or errors and are not supported. See :ref:`gotchas.udf-mutation`
for more details.

A passed user-defined-function will be passed a Series for evaluation.

If ``func`` defines an index relabeling, ``axis`` must be ``0`` or ``index``.

Examples
--------
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6], "C": [7, 8, 9]})
>>> df
   A  B  C
0  1  4  7
1  2  5  8
2  3  6  9

>>> df.ewm(alpha=0.5).mean()
          A         B         C
0  1.000000  4.000000  7.000000
1  1.666667  4.666667  7.666667
2  2.428571  5.428571  8.428571
)rT   Ú	aggregate)rd   ÚfuncÚargsÚkwargsrf   s       €r1   r|   Ú!ExponentialMovingWindow.aggregateÆ  s    ø€ ôL ‰wÒ  Ð7¨Ò7°Ñ7Ð7r3   c           
     ó  • [        U5      (       aw  U R                  S:X  a  [        nO[        nU" S0 [	        U5      DU R
                  U R                  U R                  [        U R                  5      SS.D6nU R                  USS9$ US;   at  Ub  [        S5      eU R                  c  SOU R                  n[        [        R                  U R
                  U R                  U R                  USS9nU R                  USUS	9$ [        S
5      e)a­  
Calculate the ewm (exponential weighted moment) mean.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting
      ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{'nopython': True, 'nogil': False, 'parallel': False}``

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.ewm : Calling ewm with Series data.
DataFrame.ewm : Calling ewm with DataFrames.
Series.mean : Aggregating mean for Series.
DataFrame.mean : Aggregating mean for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba` for
extended documentation and performance considerations for the Numba engine.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.ewm(alpha=0.2).mean()
0    1.000000
1    1.555556
2    2.147541
3    2.775068
dtype: float64
ÚsingleT©rH   rJ   rK   ÚdeltasÚ	normalizeÚmean©Úname©ÚcythonNNú+cython engine does not accept engine_kwargs©rˆ   Únumeric_onlyú)engine must be either 'numba' or 'cython'rj   )r   rL   r   r   r   ra   rJ   rK   Útupler_   Ú_applyr&   r@   r   Úwindow_aggregationsÚewm©rd   r�   ru   rv   r}   Úewm_funcr„   Úwindow_funcs           r1   r†   ÚExponentialMovingWindow.mean  sû   € ôl ˜6×"Ñ"Ø�{‰{˜hÓ&Ü.‘ä4�Ùñ Ü# MÓ2ðà—I‘IØ—{‘{ØŸ.™.Ü˜TŸ\™\Ó*ØóˆHð —;‘;˜x¨f�;Ð5Ð5ØÐ'Ó'ØÑ(Ü Ð!NÓOÐOà!ŸZ™ZÑ/‘T°T·\±\ˆFÜ!Ü#×'Ñ'Ø—I‘IØ—{‘{ØŸ.™.ØØñˆKð —;‘;˜{°Àl�;ÐSÐSäÐHÓIÐIr3   c           
     ó‚  • U R                   (       d  [        S5      eU R                  b  [        S5      e[        U5      (       aw  U R                  S:X  a  [
        nO[        nU" S0 [        U5      DU R                  U R                   U R                  [        U R                  5      SS.D6nU R                  USS9$ US	;   at  Ub  [        S
5      eU R                  c  SOU R                  n[        [        R                   U R                  U R                   U R                  USS9nU R                  USUS9$ [        S5      e)a™  
Calculate the ewm (exponential weighted moment) sum.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.
engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting
      ``compute.use_numba``
engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{'nopython': True, 'nogil': False, 'parallel': False}``

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.ewm : Calling ewm with Series data.
DataFrame.ewm : Calling ewm with DataFrames.
Series.sum : Aggregating sum for Series.
DataFrame.sum : Aggregating sum for DataFrame.

Notes
-----
See :ref:`window.numba_engine` and :ref:`enhancingperf.numba` for extended
documentation and performance considerations for the Numba engine.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.ewm(alpha=0.2).sum()
0    1.000
1    2.800
2    5.240
3    8.192
dtype: float64
z(sum is not implemented with adjust=FalseNz!sum is not implemented with timesr‚   Frƒ   Úsumr‡   r‰   r‹   rŒ   rŽ   rj   )rJ   r`   r@   r   rL   r   r   r   ra   rK   r�   r_   r�   r&   r   r‘   r’   r“   s           r1   r˜   ÚExponentialMovingWindow.sume  s$  € ðh �{�{Ü%Ð&PÓQÐQØ�:‰:Ñ!Ü%Ð&IÓJÐJÜ˜6×"Ñ"Ø�{‰{˜hÓ&Ü.‘ä4�Ùñ Ü# MÓ2ðà—I‘IØ—{‘{ØŸ.™.Ü˜TŸ\™\Ó*ØóˆHð —;‘;˜x¨e�;Ð4Ð4ØÐ'Ó'ØÑ(Ü Ð!NÓOÐOà!ŸZ™ZÑ/‘T°T·\±\ˆFÜ!Ü#×'Ñ'Ø—I‘IØ—{‘{ØŸ.™.ØØñˆKð —;‘;˜{°À\�;ÐRÐRäÐHÓIÐIr3   c                ó.  • U(       a_  U R                   R                  S:X  aE  [        U R                   R                  5      (       d!  [	        [        U 5      R                   S35      eU R                  b  [	        S5      e[        U R                  XS95      $ )aÆ  
Calculate the ewm (exponential weighted moment) standard deviation.

Parameters
----------
bias : bool, default False
    Use a standard estimation bias correction.
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.ewm : Calling ewm with Series data.
DataFrame.ewm : Calling ewm with DataFrames.
Series.std : Aggregating std for Series.
DataFrame.std : Aggregating std for DataFrame.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.ewm(alpha=0.2).std()
0         NaN
1    0.707107
2    0.995893
3    1.277320
dtype: float64
r#   z$.std does not implement numeric_onlyz!std is not implemented with times)Úbiasr�   )
Ú_selected_objÚndimr
   r6   r`   ÚtypeÚ__name__r@   r   Úvar©rd   r›   r�   s      r1   ÚstdÚExponentialMovingWindow.std¼  s†   € öD Ø×"Ñ"×'Ñ'¨1Ó,Ü$ T×%7Ñ%7×%=Ñ%=×>Ñ>ô &Ü˜“:×&Ñ&Ð'Ð'KÐLóð ð �:‰:Ñ!Ü%Ð&IÓJÐJÜ�T—X‘X 4�XÐCÓDÐDr3   c                óØ   ^• U R                   b  [        S5      e[        R                  n[	        UU R
                  U R                  U R                  US9mU4S jnU R                  USUS9$ )a¼  
Calculate the ewm (exponential weighted moment) variance.

Parameters
----------
bias : bool, default False
    Use a standard estimation bias correction.
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.ewm : Calling ewm with Series data.
DataFrame.ewm : Calling ewm with DataFrames.
Series.var : Aggregating var for Series.
DataFrame.var : Aggregating var for DataFrame.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4])
>>> ser.ewm(alpha=0.2).var()
0         NaN
1    0.500000
2    0.991803
3    1.631547
dtype: float64
z!var is not implemented with times)rH   rJ   rK   r›   c                ó   >• T" XX#U 5      $ ri   rj   )ÚvaluesÚbeginrl   rI   Úwfuncs       €r1   Úvar_funcÚ-ExponentialMovingWindow.var.<locals>.var_func  s   ø€ Ù˜¨¸&ÓAÐAr3   r    rŒ   )	r@   r`   r‘   Úewmcovr   ra   rJ   rK   r�   )rd   r›   r�   r•   r©   r¨   s        @r1   r    ÚExponentialMovingWindow.varê  si   ø€ ðB �:‰:Ñ!Ü%Ð&IÓJÐJÜ)×0Ñ0ˆÜØØ—	‘	Ø—;‘;Ø—n‘nØñ
ˆõ	Bð �{‰{˜8¨%¸lˆ{ÐKÐKr3   c                ó²   ^ ^^• T R                   b  [        S5      eSSKJm  T R	                  SU5        UUU 4S jnT R                  T R                  XXT5      $ )aæ  
Calculate the ewm (exponential weighted moment) sample covariance.

Parameters
----------
other : Series or DataFrame , optional
    If not supplied then will default to self and produce pairwise
    output.
pairwise : bool, default None
    If False then only matching columns between self and other will be
    used and the output will be a DataFrame.
    If True then all pairwise combinations will be calculated and the
    output will be a MultiIndex DataFrame in the case of DataFrame
    inputs. In the case of missing elements, only complete pairwise
    observations will be used.
bias : bool, default False
    Use a standard estimation bias correction.
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.ewm : Calling ewm with Series data.
DataFrame.ewm : Calling ewm with DataFrames.
Series.cov : Aggregating cov for Series.
DataFrame.cov : Aggregating cov for DataFrame.

Examples
--------
>>> ser1 = pd.Series([1, 2, 3, 4])
>>> ser2 = pd.Series([10, 11, 13, 16])
>>> ser1.ewm(alpha=0.2).cov(ser2)
0         NaN
1    0.500000
2    1.524590
3    3.408836
dtype: float64
z!cov is not implemented with timesr   ©r    Úcovc                óî  >• TR                  U 5      nTR                  U5      nTR                  5       nTR                  b  TR                  OUR                  nUR	                  [        U5      UTR                  TR                  TR                  S9u  pg[        R                  " UUUTR                  UTR                  TR                  TR                  T
5	      nT	" X€R                  U R                  SS9$ )N©Ú
num_valuesrI   rR   rS   ÚstepF©Úindexrˆ   Úcopy)Ú_prep_valuesrr   rI   Úwindow_sizeÚget_window_boundsrY   rR   rS   r³   r‘   r«   ra   rJ   rK   rµ   rˆ   )ÚxÚyÚx_arrayÚy_arrayÚwindow_indexerrI   rk   rl   Úresultr    r›   rd   s            €€€r1   Úcov_funcÚ-ExponentialMovingWindow.cov.<locals>.cov_funcT  sê   ø€ Ø×'Ñ'¨Ó*ˆGØ×'Ñ'¨Ó*ˆGØ!×5Ñ5Ó7ˆNð ×#Ñ#Ñ/ð × Ò à#×/Ñ/ð ð
 (×9Ñ9Ü˜w›<Ø'Ø—{‘{Ø—{‘{Ø—Y‘Yð :ð ‰JˆEô )×/Ò/ØØØð × Ñ ØØ—	‘	Ø—‘Ø—‘ØóˆFñ ˜&¯©°a·f±fÀ5ÑIÐIr3   ©r@   r`   Úpandasr    Ú_validate_numeric_onlyÚ_apply_pairwiserœ   )rd   ÚotherÚpairwiser›   r�   rÀ   r    s   `  `  @r1   r¯   ÚExponentialMovingWindow.cov  sW   ú€ ðd �:‰:Ñ!Ü%Ð&IÓJÐJå!à×#Ñ# E¨<Ô8÷	Jð> ×#Ñ#Ø×Ñ °ó
ð 	
r3   c                ó®   ^ ^• T R                   b  [        S5      eSSKJm  T R	                  SU5        UU 4S jnT R                  T R                  XXC5      $ )a¡  
Calculate the ewm (exponential weighted moment) sample correlation.

Parameters
----------
other : Series or DataFrame, optional
    If not supplied then will default to self and produce pairwise
    output.
pairwise : bool, default None
    If False then only matching columns between self and other will be
    used and the output will be a DataFrame.
    If True then all pairwise combinations will be calculated and the
    output will be a MultiIndex DataFrame in the case of DataFrame
    inputs. In the case of missing elements, only complete pairwise
    observations will be used.
numeric_only : bool, default False
    Include only float, int, boolean columns.

Returns
-------
Series or DataFrame
    Return type is the same as the original object with ``np.float64`` dtype.

See Also
--------
Series.ewm : Calling ewm with Series data.
DataFrame.ewm : Calling ewm with DataFrames.
Series.corr : Aggregating corr for Series.
DataFrame.corr : Aggregating corr for DataFrame.

Examples
--------
>>> ser1 = pd.Series([1, 2, 3, 4])
>>> ser2 = pd.Series([10, 11, 13, 16])
>>> ser1.ewm(alpha=0.2).corr(ser2)
0         NaN
1    1.000000
2    0.982821
3    0.977802
dtype: float64
z"corr is not implemented with timesr   r®   Úcorrc                ó*  >^
^^• TR                  U 5      nTR                  U5      nTR                  5       nTR                  b  TR                  OUR                  mUR	                  [        U5      TTR                  TR                  TR                  S9u  mm
U
UUU4S jn[        R                  " SS9   U" X#5      nU" X"5      nU" X35      nU[        Xx-  5      -  n	S S S 5        T" W	U R                  U R                  SS9$ ! , (       d  f       N+= f)Nr±   c                ó|   >• [         R                  " U TTTUTR                  TR                  TR                  S5	      $ )NT)r‘   r«   ra   rJ   rK   )ÚXÚYrl   rI   rd   rk   s     €€€€r1   Ú_covÚ<ExponentialMovingWindow.corr.<locals>.cov_func.<locals>._cov¾  s=   ø€ Ü*×1Ò1ØØØØØØ—I‘IØ—K‘KØ—N‘NØó
ð 
r3   Úignore)ÚallFr´   )r·   rr   rI   r¸   r¹   rY   rR   rS   r³   r'   Úerrstater   rµ   rˆ   )rº   r»   r¼   r½   r¾   rÏ   r¯   Úx_varÚy_varr¿   rl   rI   rk   r    rd   s             @@@€€r1   rÀ   Ú.ExponentialMovingWindow.corr.<locals>.cov_func­  s  û€ Ø×'Ñ'¨Ó*ˆGØ×'Ñ'¨Ó*ˆGØ!×5Ñ5Ó7ˆNð ×#Ñ#Ñ/ð × Ò à#×/Ñ/ð ð
 (×9Ñ9Ü˜w›<Ø'Ø—{‘{Ø—{‘{Ø—Y‘Yð :ð ‰JˆE�3÷ð ô —’ Ó*Ù˜7Ó,�Ù˜WÓ.�Ù˜WÓ.�Øœu U¡]Ó3Ñ3�÷	 +ñ
 ˜&¨¯©°a·f±fÀ5ÑIÐI÷ +Õ*ús   Â6)DÄ
DrÂ   )rd   rÆ   rÇ   r�   rÀ   r    s   `    @r1   rÊ   ÚExponentialMovingWindow.corrw  sX   ù€ ð^ �:‰:Ñ!Ü%Ð&JÓKÐKå!à×#Ñ# F¨LÔ9ö#	JðJ ×#Ñ#Ø×Ñ °ó
ð 	
r3   )	ra   r_   rJ   r.   rH   r-   rK   r,   r@   )	NNNNr   TFNr‚   )rP   r!   rH   úfloat | Noner,   rØ   r-   ú(float | TimedeltaConvertibleTypes | Noner.   rØ   rI   ú
int | NonerJ   ÚboolrK   rÛ   r@   únp.ndarray | NDFrame | NonerL   rZ   ÚreturnÚNone)rk   ú
np.ndarrayrl   rß   rm   rW   rÝ   rÞ   )rÝ   r   )ÚnumbaN)ru   rZ   rÝ   rw   ri   )FNN)r�   rÛ   ©FF©r›   rÛ   r�   rÛ   ©NNFF©rÆ   úDataFrame | Series | NonerÇ   úbool | Noner›   rÛ   r�   rÛ   ©NNF©rÆ   rå   rÇ   ræ   r�   rÛ   )rŸ   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_attributesrU   rn   rr   ry   r|   Úaggr†   r˜   r¢   r    r¯   rÊ   Ú__static_attributes__Ú__classcell__©rf   s   @r1   rF   rF   ~   sÍ  ø† ñvòp
€Kð !Ø!Ø=AØ"Ø"#ØØØ-1ØðJð ñJàðJð ðJð ð	Jð
 ;ðJð ðJð  ðJð ðJð ðJð +ðJð ðJð 
÷Jñ JðXØðØ&0ðØ<?ðà	ôô0ð 48ð'
Øð'
à	&õ'
÷RF8ðP €Cð #ØØð	SJàõSJðn #ØØð	UJàõUJön,Eö\/Lðf ,0Ø $ØØ"ðZ
à(ðZ
ð ðZ
ð ð	Z
ð
 õZ
ð| ,0Ø $Ø"ð	]
à(ð]
ð ð]
ð ÷	]
ó ]
r3   rF   c                  ót   ^ • \ rS rSrSr\R                  \R                  -   rSS.SU 4S jjjrS	S jr	Sr
U =r$ )
ÚExponentialMovingWindowGroupbyi×  z>
Provide an exponential moving window groupby implementation.
N)Ú_grouperc               ó\  >• [         TU ]  " U/UQ7SU0UD6  UR                  (       d„  U R                  bv  [        R
                  " [        U R                  R                  R                  5       5      5      n[        U R                  R                  U5      U R                  5      U l        g g g )Nrô   )rT   rU   Úemptyr@   r'   ÚconcatenateÚlistrô   Úindicesr¦   rD   Útaker-   r_   )rd   rP   rô   r~   r   Úgroupby_orderrf   s         €r1   rU   Ú'ExponentialMovingWindowGroupby.__init__ß  s   ø€ Ü‰Ò˜ÐA˜tÒA¨hÐA¸&ÒAà�y�y˜TŸZ™ZÑ3äŸNšN¬4°·±×0EÑ0E×0LÑ0LÓ0NÓ+OÓPˆMÜ,Ø—
‘
—‘ Ó.Ø—‘óˆD�Lð 4ˆyr3   c                óJ   • [        U R                  R                  [        S9nU$ )zk
Return an indexer class that will compute the window start and end bounds

Returns
-------
GroupbyIndexer
)Úgroupby_indicesr¾   )r   rô   rù   r   )rd   r¾   s     r1   rr   Ú2ExponentialMovingWindowGroupby._get_window_indexerê  s&   € ô (Ø ŸM™M×1Ñ1Ü9ñ
ˆð Ðr3   )r_   ©rÝ   rÞ   )rÝ   r   )rŸ   ré   rê   rë   rì   rF   rí   r   rU   rr   rï   rð   rñ   s   @r1   ró   ró   ×  s8   ø† ñð *×5Ñ5Ð8I×8UÑ8UÑU€Kà,0÷ 	ò 	÷ò r3   ró   c                  óü   ^ • \ rS rSr          SSS.                       SU 4S jjjjrSS jrSS jrSSS jjr   S     SS jjr    S       SS	 jjr	SSS
 jjr
SSS.S jrSrU =r$ )rw   iù  NrM   c               ó  >• U	b  [        S5      e[        TU ]	  UUUUUUUUU	US9
  [        U R                  U R
                  U R                  UR                  5      U l        [        U
5      (       a  X l
        X°l        g [        S5      e)Nz0times is not implemented with online operations.)
rP   rH   r,   r-   r.   rI   rJ   rK   r@   rN   z$'numba' is the only supported engine)r`   rT   rU   r   ra   rJ   rK   rc   Ú_meanr   ru   rv   r&   )rd   rP   rH   r,   r-   r.   rI   rJ   rK   r@   ru   rv   rN   rf   s                €r1   rU   Ú&OnlineExponentialMovingWindow.__init__ú  s“   ø€ ð  ÑÜ%ØBóð ô 	‰ÑØØØØØØ#ØØØØð 	ñ 	
ô " $§)¡)¨T¯[©[¸$¿.¹.È#Ï)É)ÓTˆŒ
Ü˜6×"Ñ"Ø ŒKØ!.ÕäÐCÓDÐDr3   c                ó8   • U R                   R                  5         g)z-
Reset the state captured by `update` calls.
N)r  Úresetrq   s    r1   r  Ú#OnlineExponentialMovingWindow.reset!  s   € ð 	�
‰
×ÑÕr3   c                ó   • [        S5      e)Nzaggregate is not implemented.©r`   )rd   r}   r~   r   s       r1   r|   Ú'OnlineExponentialMovingWindow.aggregate'  s   € Ü!Ð"AÓBÐBr3   c                ó   • [        S5      e)Nzstd is not implemented.r	  )rd   r›   r~   r   s       r1   r¢   Ú!OnlineExponentialMovingWindow.std*  ó   € Ü!Ð";Ó<Ð<r3   c                ó   • [        S5      e)Nzcorr is not implemented.r	  )rd   rÆ   rÇ   r�   s       r1   rÊ   Ú"OnlineExponentialMovingWindow.corr-  s   € ô "Ð"<Ó=Ð=r3   c                ó   • [        S5      e)Nzcov is not implemented.r	  )rd   rÆ   rÇ   r›   r�   s        r1   r¯   Ú!OnlineExponentialMovingWindow.cov5  s   € ô "Ð";Ó<Ð<r3   c                ó   • [        S5      e)Nzvar is not implemented.r	  r¡   s      r1   r    Ú!OnlineExponentialMovingWindow.var>  r  r3   )ÚupdateÚupdate_timesc               ó¼  • 0 nU R                   R                  S:H  nUb  [        S5      e[        R                  " [        U R                   R                  S   S-
  S5      [        R                  S9nUbÀ  U R                  R                  c  [        S5      eSnUR                  US	'   U(       a;  U R                  R                  [        R                  SS24   n	UR                  US
'   O%U R                  R                  n	UR                  US'   [        R                  " X‘R!                  5       45      n
OŒSnU R                   R                  US	'   U(       a  U R                   R                  US
'   OU R                   R                  US'   U R                   R#                  [        R                  5      R!                  5       n
[%        S0 ['        U R(                  5      D6nU R                  R+                  U(       a  U
OU
SS2[        R                  4   UU R,                  U5      nU(       d  UR/                  5       nXÈS nU R                   R0                  " U40 UD6nU$ )a3  
Calculate an online exponentially weighted mean.

Parameters
----------
update: DataFrame or Series, default None
    New values to continue calculating the
    exponentially weighted mean from the last values and weights.
    Values should be float64 dtype.

    ``update`` needs to be ``None`` the first time the
    exponentially weighted mean is calculated.

update_times: Series or 1-D np.ndarray, default None
    New times to continue calculating the
    exponentially weighted mean from the last values and weights.
    If ``None``, values are assumed to be evenly spaced
    in time.
    This feature is currently unsupported.

Returns
-------
DataFrame or Series

Examples
--------
>>> df = pd.DataFrame({"a": range(5), "b": range(5, 10)})
>>> online_ewm = df.head(2).ewm(0.5).online()
>>> online_ewm.mean()
      a     b
0  0.00  5.00
1  0.75  5.75
>>> online_ewm.mean(update=df.tail(3))
          a         b
2  1.615385  6.615385
3  2.550000  7.550000
4  3.520661  8.520661
>>> online_ewm.reset()
>>> online_ewm.mean()
      a     b
0  0.00  5.00
1  0.75  5.75
r$   Nz update_times is not implemented.éÿÿÿÿr#   r   r5   z;Must call mean with update=None first before passing updaterµ   Úcolumnsrˆ   rj   )rœ   r�   r`   r'   rb   rV   rc   r<   r  Úlast_ewmr&   rµ   Únewaxisr  rˆ   r÷   Úto_numpyÚastyper   r   rv   Úrun_ewmrI   ÚsqueezeÚ_constructor)rd   r  r  r~   r   Úresult_kwargsÚis_frameÚupdate_deltasÚresult_fromÚ
last_valueÚnp_arrayÚ	ewma_funcr¿   s                r1   r†   Ú"OnlineExponentialMovingWindow.meanA  s  € ðX ˆØ×%Ñ%×*Ñ*¨aÑ/ˆØÑ#Ü%Ð&HÓIÐIÜŸšÜ�×"Ñ"×(Ñ(¨Ñ,¨qÑ0°!Ó4¼B¿J¹Jñ
ˆð ÑØ�z‰z×"Ñ"Ñ*Ü ØQóð ð ˆKØ%+§\¡\ˆM˜'Ñ"ÞØ!ŸZ™Z×0Ñ0´·±ºQ°Ñ?�
Ø+1¯>©>�˜iÒ(à!ŸZ™Z×0Ñ0�
Ø(.¯©�˜fÑ%Ü—~’~ z·?±?Ó3DÐ&EÓF‰HàˆKØ%)×%7Ñ%7×%=Ñ%=ˆM˜'Ñ"ÞØ+/×+=Ñ+=×+EÑ+E�˜iÒ(à(,×(:Ñ(:×(?Ñ(?�˜fÑ%Ø×)Ñ)×0Ñ0´·±Ó<×EÑEÓGˆHÜ3ñ 
Ü × 2Ñ 2Ó3ñ
ˆ	ð —‘×#Ñ#Þ ‰H hªq´"·*±*¨}Ñ&=ØØ×ÑØó	
ˆö Ø—^‘^Ó%ˆFØ˜Ð%ˆØ×#Ñ#×0Ò0°ÑI¸=ÑIˆØˆr3   )r  ru   rv   )
NNNNr   TFNrà   N)rP   r!   rH   rØ   r,   rØ   r-   rÙ   r.   rØ   rI   rÚ   rJ   rÛ   rK   rÛ   r@   rÜ   ru   rZ   rv   zdict[str, bool] | NonerÝ   rÞ   r   ri   )F)r›   rÛ   rç   rè   rã   rä   rá   râ   )rŸ   ré   rê   rë   rU   r  r|   r¢   rÊ   r¯   r    r†   rï   rð   rñ   s   @r1   rw   rw   ù  sJ  ø† ð !Ø!Ø=AØ"Ø"#ØØØ-1ØØ04ð%Eð ñ%Eàð%Eð ð%Eð ð	%Eð
 ;ð%Eð ð%Eð  ð%Eð ð%Eð ð%Eð +ð%Eð ð%Eð .ð%Eð 
÷%Eñ %EôNôCö=ð
 ,0Ø $Ø"ð	>à(ð>ð ð>ð õ	>ð ,0Ø $ØØ"ð=à(ð=ð ð=ð ð	=ð
 õ=ö=ð "&°D÷ Vó Vr3   rw   )
r+   rØ   r,   rØ   r-   rØ   r.   rØ   rÝ   r*   )r@   znp.ndarray | NDFramer-   rÙ   rÝ   znpt.NDArray[np.float64])@Ú
__future__r   r[   Ú	functoolsr   Útypingr   r   Únumpyr'   Úpandas._libs.tslibsr   Ú pandas._libs.window.aggregationsÚ_libsÚwindowÚaggregationsr‘   Úpandas.util._decoratorsr   Úpandas.core.dtypes.commonr	   r
   Úpandas.core.dtypes.dtypesr   Úpandas.core.dtypes.genericr   Úpandas.core.dtypes.missingr   Úpandas.corer   Úpandas.core.arrays.datetimeliker   Úpandas.core.indexers.objectsr   r   r   Úpandas.core.util.numba_r   r   Úpandas.core.window.commonr   Úpandas.core.window.numba_r   r   Úpandas.core.window.onliner   r   Úpandas.core.window.rollingr   r   Úpandas._typingr   r   r   rÃ   r   r    Úpandas.core.genericr!   r2   rD   rF   ró   rw   rj   r3   r1   Ú<module>r@     s#  ðÝ "ã Ý ÷ó
 å )ß >Ó >Ý .÷õ 6Ý 0Ý +å Ý 9÷ñ ÷
õ ,÷÷÷ö
 ÷ñ ÷õ ,ðØðà
ðð ðð ð	ð
 ôðB'Øð'à6ð'ð ô'ñ< ÐÓ ôU
˜jó U
ó !ðU
ñp ÐÓ ôÐ%6Ð8Oó ó !ðôB^Ð$;õ ^r3   