Sindbad~EG File Manager
�
Mٜgv� � �� � d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl Z
d dlmZ d dl
mc mc mZ d dlmZ d dlmZmZ d d lmZ d d
lmZ d dlmZ d dlmZ d d
lm Z d dl!m"Z"m#Z#m$Z$ d dl%m&Z&m'Z' d dl(m)Z) d dl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 d dl3m4Z4m5Z5 d dl6m7Z7m8Z8 d dl9m:Z:m;Z; erd dl<m=Z=m>Z>m?Z? d dl@mAZAmBZB d dlCmDZD d d�ZE d!d�ZF G d� de:� ZG G d� de;eG� ZH G d� deG� ZIy)"� )�annotationsN)�partial)�dedent)�
TYPE_CHECKING)� Timedelta)�doc)�is_datetime64_dtype�is_numeric_dtype)�DatetimeTZDtype)� ABCSeries)�isna)�common)�
dtype_to_unit)�BaseIndexer�ExponentialMovingWindowIndexer�GroupbyIndexer)�get_jit_arguments�maybe_use_numba)�zsqrt)�_shared_docs�create_section_header�kwargs_numeric_only�numba_notes�template_header�template_returns�template_see_also�window_agg_numba_parameters)�generate_numba_ewm_func�generate_numba_ewm_table_func)�EWMMeanState�generate_online_numba_ewma_func)�
BaseWindow�BaseWindowGroupby)�Axis�TimedeltaConvertibleTypes�npt)� DataFrame�Series)�NDFramec �� � t j | |||� }|dkD rt d� �| �| dk r�t d� �|�#|dk rt d� �|dz
dz } t
| � S |�Q|dk rt d� �dt j t j
d� |z � z
}d|z dz
} t
| � S |�(|dk s|dkD rt d � �d|z
|z } t
| � S t d
� �t
| � S )N� z8comass, span, halflife, and alpha are mutually exclusiver z comass must satisfy: comass >= 0zspan 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 �A/usr/local/lib/python3.12/site-packages/pandas/core/window/ewm.py�get_center_of_massr: G 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 �r � t | j � }t | t � r| j } t j | j t
j � t
j �� }t t |� j |� j � }t j |� |z S )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
��dtype)r r>