这里我们提供了一系列方法,旨在提供分层一致的概率分布,这意味着它们可以生成具有分层线性约束的多元时间序列样本。

我们设计这些方法是为了扩展 core.HierarchicalForecast 功能类。在此处查看它们的使用示例

1. 正态性


正态性

 Normality (S:numpy.ndarray, P:numpy.ndarray, y_hat:numpy.ndarray,
            sigmah:numpy.ndarray, W:numpy.ndarray, seed:int=0)

*正态性概率协调类。

正态性方法利用高斯分布的线性特性,生成分层一致的预测分布。此类旨在用作 sampler 输入,就像其他 HierarchicalForecast 协调类一样。

假设基础预测服从正态分布:y^hN(μ^,W^h)\hat{y}_{h} \sim \mathrm{N}(\hat{\boldsymbol{\mu}}, \hat{\mathbf{W}}_{h})

协调后的预测也服从正态分布

y~hN(SPμ^,SPW^hPS) \tilde{y}_{h} \sim \mathrm{N}(\mathbf{S}\mathbf{P}\hat{\boldsymbol{\mu}}, \mathbf{S}\mathbf{P}\hat{\mathbf{W}}_{h} \mathbf{P}^{\intercal} \mathbf{S}^{\intercal})

参数
S: np.array, 维度为 (base, bottom) 的求和矩阵。
P: np.array, 维度为 (bottom, base) 的协调矩阵。
y_hat: 维度为 (base, horizon) 的点预测值。
W: np.array, 维度为 (base, base) 的分层协方差矩阵。
sigmah: np.array, 维度为 (base, horizon) 的预测标准差。
num_samples: int, 生成的 bootstrap 样本数量。
seed: int, 用于 numpy 生成器可重现性的随机种子。

参考文献
- Panagiotelis A., Gamakumara P. Athanasopoulos G., and Hyndman R. J. (2022). “Probabilistic forecast reconciliation: Properties, evaluation and score optimisation”. European Journal of Operational Research.*


Normality.get_samples

 Normality.get_samples (num_samples:int)

*正态性一致样本。

在正态性假设下获得一致样本。

参数
num_samples: int, 从一致分布中生成的样本数量。

返回
samples: 维度为 (base, horizon, num_samples) 的一致样本。*

2. Bootstrap


Bootstrap

 Bootstrap (S:numpy.ndarray, P:numpy.ndarray, y_hat:numpy.ndarray,
            y_insample:numpy.ndarray, y_hat_insample:numpy.ndarray,
            num_samples:int=100, seed:int=0, W:numpy.ndarray=None)

*Bootstrap 概率协调类。

该方法超越了对基础预测的正态性假设,通过模拟未来样本路径并利用它们生成随后进行协调的基础样本路径。这个巧妙的想法及其简单性使得可以为任何协调策略生成一致的 bootstrap 预测区间。此类旨在用作 sampler 输入,就像其他 HierarchicalForecast 协调类一样。

假设有一组 bootstrap 模拟的样本路径:(y^τ[1],,y^τ[B])(\hat{\mathbf{y}}^{[1]}_{\tau}, \dots ,\hat{\mathbf{y}}^{[B]}_{\tau})

协调后的样本路径允许进行协调后的分布预测:(SPy^τ[1],,SPy^τ[B])(\mathbf{S}\mathbf{P}\hat{\mathbf{y}}^{[1]}_{\tau}, \dots ,\mathbf{S}\mathbf{P}\hat{\mathbf{y}}^{[B]}_{\tau})

参数
S: np.array, 维度为 (base, bottom) 的求和矩阵。
P: np.array, 维度为 (bottom, base) 的协调矩阵。
y_hat: 维度为 (base, horizon) 的点预测值。
y_insample: 维度为 (base, insample_size) 的样本内值。
y_hat_insample: 维度为 (base, insample_size) 的样本内点预测值。
num_samples: int, 生成的 bootstrap 样本数量。
seed: int, 用于 numpy 生成器可重现性的随机种子。

参考文献
- Puwasala Gamakumara 博士论文. Monash University, Econometrics and Business Statistics (2020). “Probabilistic Forecast Reconciliation” - Panagiotelis A., Gamakumara P. Athanasopoulos G., and Hyndman R. J. (2022). “Probabilistic forecast reconciliation: Properties, evaluation and score optimisation”. European Journal of Operational Research.*


Bootstrap.get_samples

 Bootstrap.get_samples (num_samples:int)

*Bootstrap 样本协调方法。

应用 Gamakumara 2020 定义的 Bootstrap 样本协调方法。生成独立的样本路径并使用 Bootstrap 对其进行协调。

参数
num_samples: int, 从一致分布中生成的样本数量。

返回
samples: 维度为 (base, horizon, num_samples) 的一致样本。*

3. PERMBU


PERMBU

 PERMBU (S:numpy.ndarray, tags:dict[str,numpy.ndarray],
         y_hat:numpy.ndarray, y_insample:numpy.ndarray,
         y_hat_insample:numpy.ndarray, sigmah:numpy.ndarray,
         num_samples:Optional[int]=None, seed:int=0, P:numpy.ndarray=None)

*PERMBU 概率协调类。

PERMBU 方法利用经验底层边缘分布和经验 Copula 函数(描述底层依赖关系),通过 BottomUp 协调生成聚合层分布的分布。PERMBU 方法中的样本重新排序技术将多元依赖关系重新注入到独立的底层样本中。

Algorithm:
1.   For all series compute conditional marginals distributions.
2.   Compute residuals $\hat{\epsilon}_{i,t}$ and obtain rank permutations.
2.   Obtain K-sample from the bottom-level series predictions.
3.   Apply recursively through the hierarchical structure:<br/>
    3.1.   For a given aggregate series $i$ and its children series:<br/>
    3.2.   Obtain children's empirical joint using sample reordering copula.<br/>
    3.2.   From the children's joint obtain the aggregate series's samples.    

参数
S: np.array, 维度为 (base, bottom) 的求和矩阵。
tags: 每个键表示一个级别,每个值表示其 S 索引。
y_insample: 维度为 (base, insample_size) 的样本内值。
y_hat_insample: 维度为 (base, insample_size) 的样本内点预测值。
sigmah: np.array, 维度为 (base, horizon) 的预测标准差。
num_samples: int, 生成的正常预测样本数量。
seed: int, 用于 numpy 生成器可重现性的随机种子。

参考文献
- Taieb, Souhaib Ben and Taylor, James W and Hyndman, Rob J. (2017). Coherent probabilistic forecasts for hierarchical time series. International conference on machine learning ICML.*


PERMBU.get_samples

 PERMBU.get_samples (num_samples:Optional[int]=None)

*PERMBU 样本协调方法。

应用 Taieb 等人(2017)定义的 PERMBU 协调方法。生成独立的基础预测样本,使用估计的 Copula 函数通过重新排序恢复其多元依赖关系,并将 BottomUp 聚合应用于新样本。

参数
num_samples: int, 从一致分布中生成的样本数量。

返回
samples: 维度为 (base, horizon, num_samples) 的一致样本。*

参考文献