Exemple #1
0
def test_expanding_consistency_cov(consistency_data, min_periods):
    x, is_constant, no_nans = consistency_data
    moments_consistency_cov_data(
        x=x,
        var_unbiased=lambda x: x.expanding(min_periods=min_periods).var(),
        cov_unbiased=lambda x, y: x.expanding(min_periods=min_periods).cov(y),
        var_biased=lambda x: x.expanding(min_periods=min_periods).var(ddof=0),
        cov_biased=lambda x, y: x.expanding(min_periods=min_periods).cov(y, ddof=0),
    )
Exemple #2
0
def test_rolling_consistency_cov(consistency_data, window, min_periods,
                                 center):
    x, is_constant, no_nans = consistency_data
    moments_consistency_cov_data(
        x=x,
        var_unbiased=lambda x: (x.rolling(
            window=window, min_periods=min_periods, center=center).var()),
        cov_unbiased=lambda x, y: (x.rolling(
            window=window, min_periods=min_periods, center=center).cov(y)),
        var_biased=lambda x:
        (x.rolling(window=window, min_periods=min_periods, center=center).var(
            ddof=0)),
        cov_biased=lambda x, y:
        (x.rolling(window=window, min_periods=min_periods, center=center).cov(
            y, ddof=0)),
    )
def test_ewm_consistency_cov(consistency_data, min_periods, adjust, ignore_na):
    x, is_constant, no_nans = consistency_data
    com = 3.0
    moments_consistency_cov_data(
        x=x,
        var_unbiased=lambda x: (x.ewm(com=com,
                                      min_periods=min_periods,
                                      adjust=adjust,
                                      ignore_na=ignore_na).var(bias=False)),
        cov_unbiased=lambda x, y:
        (x.ewm(com=com,
               min_periods=min_periods,
               adjust=adjust,
               ignore_na=ignore_na).cov(y, bias=False)),
        var_biased=lambda x: (x.ewm(com=com,
                                    min_periods=min_periods,
                                    adjust=adjust,
                                    ignore_na=ignore_na).var(bias=True)),
        cov_biased=lambda x, y: (x.ewm(com=com,
                                       min_periods=min_periods,
                                       adjust=adjust,
                                       ignore_na=ignore_na).cov(y, bias=True)),
    )