-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A
min_weight
param to exp functions (#108)
* Proposal for a `min_weight` param to exp functions One issue with using the current exp functions is that there's no `min_periods` parameter, meaning that initial results can be overly influenced by a couple of values. This PR adds a `min_weight` parameter to the exp functions, which is the minimum weight that a value requires before producing a value. Assuming that `alpha` is constant, this is equivalent to taking a rolling sum of `1` or `0`s and then passing the original result where the corresponding value of the rolling sum is greater than `min_weight/alpha`. So for a series with a slower moving average (i.e. a lower alpha), we require more points to be present before producing a value. Similarly, a higher `min_weight` value will require more points to be present. If all values exist, then the value of `1/alpha` will asymptotically approach 1 — so a `min_weight` of 1 will never produce values. * Speed up `nanmean` & `nansum` by 20% & 50% by yolo-ing NaNs This has a surprisingly large effect on the speed of these routines, and without any loss of accuracy. * Apply `NaN` handling to `rolling_exp_nanvar` This speeds up `rolling_exp_nanvar` 5-10% It will likely be slower if there are lots of leading `NaN`s; but I don't expect that's an overridingly common case, and this also makes the code simpler * Remove some of the attempts to speed it up, it's surprisingly fast already * Update numbagg/moving.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add pandas comparison `nansum` test * Add back checks for `nansum`, which can't use `denom` to assess whether it's seen values * Refine benchmarks * more thorough testing --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6670eb0
commit 843de2a
Showing
4 changed files
with
118 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters