-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
Numeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operationsPerformanceMemory or execution speed performanceMemory or execution speed performanceWindowrolling, ewma, expandingrolling, ewma, expanding
Milestone
Description
The numerical stability of the current implementation of rolling_kurt
and rolling_skew
is very poor:
In [14]: x = np.random.rand(10)
In [15]: pd.Series(x).rolling(4).skew()
Out[15]:
0 NaN
1 NaN
2 NaN
3 -0.971467
4 0.596391
5 -1.163135
6 -0.611469
7 -1.624713
8 -0.021832
9 0.754653
dtype: float64
In [16]: pd.Series(x + 5000).rolling(4).skew()
Out[16]:
0 NaN
1 NaN
2 NaN
3 -0.968964
4 0.608522
5 -1.171751
6 -0.619354
7 -1.628942
8 -0.033949
9 0.741304
dtype: float64
In [17]: pd.Series(x).rolling(4).kurt()
Out[17]:
0 NaN
1 NaN
2 NaN
3 2.030185
4 -2.647975
5 1.183004
6 -2.178587
7 2.658058
8 -4.258505
9 0.939264
dtype: float64
In [18]: pd.Series(x + 100).rolling(4).kurt()
Out[18]:
0 NaN
1 NaN
2 NaN
3 2.030230
4 -2.648801
5 1.182382
6 -2.178574
7 2.657934
8 -4.258813
9 0.938661
dtype: float64
This can be solved using an updating algorithm, similar to what is done in #6817 for rolling_var
.
Metadata
Metadata
Assignees
Labels
Numeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operationsPerformanceMemory or execution speed performanceMemory or execution speed performanceWindowrolling, ewma, expandingrolling, ewma, expanding