Skip to content

DOC: fix conflicting ewma documentation #4499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions doc/source/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ average as

.. math::

y_t = \alpha y_{t-1} + (1 - \alpha) x_t
y_t = (1 - \alpha) y_{t-1} + \alpha x_t

One must have :math:`0 < \alpha \leq 1`, but rather than pass :math:`\alpha`
directly, it's easier to think about either the **span** or **center of mass
Expand All @@ -461,9 +461,19 @@ directly, it's easier to think about either the **span** or **center of mass
\alpha =
\begin{cases}
\frac{2}{s + 1}, s = \text{span}\\
\frac{1}{c + 1}, c = \text{center of mass}
\frac{1}{1 + c}, c = \text{center of mass}
\end{cases}

.. note::

the equation above is sometimes written in the form

.. math::

y_t = \alpha' y_{t-1} + (1 - \alpha') x_t

where :math:`\alpha' = 1 - \alpha`.

You can pass one or the other to these functions but not both. **Span**
corresponds to what is commonly called a "20-day EW moving average" for
example. **Center of mass** has a more physical interpretation. For example,
Expand Down
8 changes: 4 additions & 4 deletions pandas/stats/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
----------
%s
com : float. optional
Center of mass: \alpha = com / (1 + com),
Center of mass: :math:`\alpha = 1 / (1 + com)`,
span : float, optional
Specify decay in terms of span, \alpha = 2 / (span + 1)
Specify decay in terms of span, :math:`\alpha = 2 / (span + 1)`
min_periods : int, default 0
Number of observations in sample to require (only affects
beginning)
Expand All @@ -75,8 +75,8 @@
Either center of mass or span must be specified

EWMA is sometimes specified using a "span" parameter s, we have have that the
decay parameter \alpha is related to the span as
:math:`\alpha = 1 - 2 / (s + 1) = c / (1 + c)`
decay parameter :math:`\alpha` is related to the span as
:math:`\alpha = 2 / (s + 1) = 1 / (1 + c)`

where c is the center of mass. Given a span, the associated center of mass is
:math:`c = (s - 1) / 2`
Expand Down