Statistics
Methods which provide common statistics.
- signal.z_score(*, num_periods, min_periods=None, delay_periods=1)
Given a stationary time series (signal), calculate a rolling window z-score. The signal is assumed to be stationary and normally distributed.
- Parameters:
num_periods – The number of time-periods of the signal to include in the estimate. That is, for a daily signal like
close_price.relative_change(days=1)
, this argument is the number of days.min_periods – The minimum number of actual data-points before estimate is produced. If
min_periods
is not specified, then it is set equal tonum_periods
.delay_periods – The number of periods before the estimated model is applied to the current data point.
Example:
Calculate the z-scores of the price movements over the past 90 days:
close_price.relative_change(days=1).z_score(num_periods=90)
- signal.p_value(num_periods, min_periods=None, delay_periods=1, p_cap=0.0)
Given a stationary time series (signal), calculate rolling p-values. The signal is assumed to be stationary and normally distributed.
- Parameters:
num_periods – The number of time-periods of the signal to include in the estimate. That is, for a daily signal like
close_price.relative_change(days=1)
, this argument is the number of days.min_periods – The minimum number of actual data-points before estimate is produced. If
min_periods
is not specified, then it is set equal tonum_periods
.delay_periods – The number of periods before the estimated model is applied to the current data point.
p_cap – A lower threshold on the p-values to be returned (lower values are removed)
Examples:
Calculate the p-values of the price movements over the past 90 days:
close_price.relative_change(days=1).p_value(num_periods=90, min_periods=50)
A simple outlier detector:
close_price.relative_change(days=1).p_value(num_periods=90, min_periods=50, p_cap=0.9999)