Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] docstring with mathematical description for QPD_Empirical #255

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions skpro/distributions/qpd_empirical.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,40 @@


class QPD_Empirical(Empirical):
"""Empirical quantile parametrized distribution.

This distribution is parameterized by a set of quantile points.

todo: add docstr
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`
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_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.

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 = -p_1` and :math:`p_{N+1} = 2 - p_N`.
Comment on lines +33 to +37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question:
you say: such that w_i = (p_{i+1} - p_{i-1})/2 for 1 = 1, \dots, N and then you define p_0 and p_{N+1}. Why you define them? How are these two values playing a role here?

Copy link
Collaborator Author

@fkiraly fkiraly Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$w_i$ is defined in terms of $p_{i+1}$ and $p_{i-1}$ for $i= 1\dots N$, and $p_i$ have been defined above also only for $i= 1\dots N$.

So we need to treat $w_1$, $w_N$, either by writing them down explicitly, or by writing equivalent values for $p_0$, $p_{N+1}$. I thought the latter was clearer, in terms how the boundary treatment looks like?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry now I see ;-)

thanks for the explanation. I didn't check that there it was a p_{i-1}) and we have to define p_0 (same for p_{i+1}

Copy link
Collaborator Author

@fkiraly fkiraly Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the $w_i$ should sum to 1, hopefully. The weights should make it that the steps in the ppf are exactly in the middle between two adjacent $p_i$.


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
----------
Expand Down
Loading