Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
ENH: Allow exponentially weighted functions to specify alpha directly #12492
Conversation
|
I am not sure we do any validity checks on any com parameters eg is alpha=0 valid? |
|
That's actually a question I had. Zero alpha is not okay, but zero half-life isn't either, and the code is not checking for that. Should I add the checks for |
|
yep I think we need some sanity checks as well here - raising a helpful ValueError would be nice (rather than giving weird/odd results) |
jreback
commented on an outdated diff
Mar 1, 2016
jreback
added this to the
0.18.0
milestone
Mar 1, 2016
jreback
added API Design Numeric
labels
Mar 1, 2016
|
thanks @evectant just minor comments. |
|
@jreback: Added the comments, slightly reworded the description in computation.rst. Pushed and green. |
jreback
commented on an outdated diff
Mar 2, 2016
jreback
commented on an outdated diff
Mar 2, 2016
| \end{cases} | ||
| -One must specify precisely one of the three to the EW functions. **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, | ||
| -**span** = 20 corresponds to **com** = 9.5. **Halflife** is the period of | ||
| -time for the exponential weight to reduce to one half. | ||
| +One must specify precisely one of **span**, **center of mass**, **half-life** | ||
| +and **alpha** to the EW functions. **Span** corresponds to what is commonly |
|
|
jreback
commented on an outdated diff
Mar 2, 2016
| \end{cases} | ||
| -One must specify precisely one of the three to the EW functions. **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, | ||
| -**span** = 20 corresponds to **com** = 9.5. **Halflife** is the period of | ||
| -time for the exponential weight to reduce to one half. | ||
| +One must specify precisely one of **span**, **center of mass**, **half-life** | ||
| +and **alpha** to the EW functions. **Span** corresponds to what is commonly | ||
| +called an "N-day EW moving average". **Center of mass** has a more physical | ||
| +interpretation and can be thought of in terms of span: :math:`c = (s - 1) / 2`. | ||
| +**Half-life** is the period of time for the exponential weight to reduce to |
jreback
Contributor
|
jreback
commented on an outdated diff
Mar 2, 2016
| @@ -1037,7 +1041,7 @@ class EWM(_Rolling): | ||
| Notes | ||
| ----- | ||
| - Either center of mass, span or halflife must be specified | ||
| + Either center of mass, span, half-life or alpha must be specified | ||
| EWMA is sometimes specified using a "span" parameter `s`, we have that the | ||
| decay parameter :math:`\alpha` is related to the span as |
jreback
Contributor
|
jreback
commented on an outdated diff
Mar 2, 2016
|
looks good. just some minor documentation comments. |
|
pls rebase and push again, master has been updated |
jreback
commented on an outdated diff
Mar 6, 2016
jreback
commented on an outdated diff
Mar 6, 2016
| decay = 1 - np.exp(np.log(0.5) / halflife) | ||
| com = 1 / decay - 1 | ||
| - elif com is None: | ||
| - raise Exception("Must pass one of com, span, or halflife") | ||
| + elif alpha is not None: | ||
| + if alpha <= 0 or alpha > 1: | ||
| + raise ValueError("alpha must satisfy: 0 < alpha <= 1") | ||
| + com = (1.0 - alpha) / alpha | ||
| + else: | ||
| + raise Exception("Must pass one of com, span, halflife, or alpha") | ||
|
|
|
@jreback: Pushed and green. |
jreback
closed this
in 547c784
Mar 6, 2016
|
thanks @evectant great PR! |
|
give a look at the built documentation (should be done shortly), http://pandas-docs.github.io/pandas-docs-travis/ and make sure looks ok (obviously where you changed things!). If not pls issue a follow. |
evectant
referenced
this pull request
Mar 6, 2016
Closed
BLD: Install texlive packages in Travis CI #12544
|
@jreback The docs look good to me. Thanks for your help with the commit. |
|
looks good thanks for the PR! |
evectant commentedFeb 29, 2016