From 2ff7a4e2571876d49294cc519f9d9b1c9f6d6af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Thu, 18 Apr 2024 13:56:54 +0100 Subject: [PATCH 1/3] Update qpd_empirical.py --- skpro/distributions/qpd_empirical.py | 35 +++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/skpro/distributions/qpd_empirical.py b/skpro/distributions/qpd_empirical.py index fb7a459b5..3b8e6396e 100644 --- a/skpro/distributions/qpd_empirical.py +++ b/skpro/distributions/qpd_empirical.py @@ -12,9 +12,38 @@ class QPD_Empirical(Empirical): """Empirical quantile parametrized distribution. - This distribution is parameterized by a set of quantile points. - - todo: add docstr + This distribution is parameterized by a set of quantile points and quantiles, + quantiles :math:`q_1, q_2, \dots, q_N` + at quantile points :math:`p_1, p_2, \dots, p_N`, + with :math:`0 \le p_1 < p_2 < \dots < p_N \le 1`. + + It represents a distribution with piecewise constant CDF and quantile function, + the unique distribution satisfying: + + * the support is :math:`[q_1, q_N]` + * for any quantile point :math:`p \in [p_i, p_{i+1}]`, it holds that + :math:`\mbox{ppf}(p) = :math:`\mbox{ppf}(p_i)`, + where :math:`i` is the index minimizing :math:`|p_i - p|`, + in all cases where this minimizer is unique. + + In vernacular terms, the quantile function agrees with the quantiles prescribed by + :math:`q_i` at the quantile points :math:`p_i`, and for other quantile points + agrees with the value at the nearest quantile point. + + In explicit terms, the distribution is an empirical distribution (sum-of-diracs), + supported at the quantiles :math:`q_1, q_2, \dots, q_N`, + with weights :math:`w_1, w_2, \dots, w_N` + such that :math:`w_i = (p_{i+1} - p_{i-1})/2` for :math:`1 = 1, \dots, N`, + where we define :math:`p_0 = 0` and :math:`p_{N+1} = 2`. + + Formally, the distribution is parametrized by the quantiles :math:`q_i` + and the quantile points :math:`p_i`, not by the quantiles and weights :math:`w_i`, + so it is distinct from the empirical distribution (``skpro`` ``Empirical``), + as a parameterized distribution, + by being quantile parameterized and not sample parameterized. + + However, it is equivalent, as an unparameterized distribution, + to an ``Empirical`` distribution with weights and nodes given as above. Parameters ---------- From 5da33e4a90a19aeadec4a4ddb26b83f005d62f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Thu, 18 Apr 2024 14:18:30 +0100 Subject: [PATCH 2/3] Update qpd_empirical.py --- skpro/distributions/qpd_empirical.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skpro/distributions/qpd_empirical.py b/skpro/distributions/qpd_empirical.py index 3b8e6396e..7e197106a 100644 --- a/skpro/distributions/qpd_empirical.py +++ b/skpro/distributions/qpd_empirical.py @@ -21,8 +21,8 @@ class QPD_Empirical(Empirical): the unique distribution satisfying: * the support is :math:`[q_1, q_N]` - * for any quantile point :math:`p \in [p_i, p_{i+1}]`, it holds that - :math:`\mbox{ppf}(p) = :math:`\mbox{ppf}(p_i)`, + * for any quantile point :math:`p \in [p_1, p_N]`, it holds that + :math:`\mbox{ppf}(p)` = :math:`\mbox{ppf}(p_i)`, where :math:`i` is the index minimizing :math:`|p_i - p|`, in all cases where this minimizer is unique. From 7d9bab3c0a3f1c3305f84415282ef5e330ee37f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Thu, 18 Apr 2024 14:28:39 +0100 Subject: [PATCH 3/3] fix formula and formatting --- skpro/distributions/qpd_empirical.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skpro/distributions/qpd_empirical.py b/skpro/distributions/qpd_empirical.py index 7e197106a..9f7596478 100644 --- a/skpro/distributions/qpd_empirical.py +++ b/skpro/distributions/qpd_empirical.py @@ -10,7 +10,7 @@ class QPD_Empirical(Empirical): - """Empirical quantile parametrized distribution. + r"""Empirical quantile parametrized distribution. This distribution is parameterized by a set of quantile points and quantiles, quantiles :math:`q_1, q_2, \dots, q_N` @@ -34,7 +34,7 @@ class QPD_Empirical(Empirical): supported at the quantiles :math:`q_1, q_2, \dots, q_N`, with weights :math:`w_1, w_2, \dots, w_N` such that :math:`w_i = (p_{i+1} - p_{i-1})/2` for :math:`1 = 1, \dots, N`, - where we define :math:`p_0 = 0` and :math:`p_{N+1} = 2`. + where we define :math:`p_0 = -p_1` and :math:`p_{N+1} = 2 - p_N`. Formally, the distribution is parametrized by the quantiles :math:`q_i` and the quantile points :math:`p_i`, not by the quantiles and weights :math:`w_i`,