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

include quantile function in distribution #314

Merged
merged 1 commit into from
Sep 16, 2019

Conversation

vafl
Copy link
Contributor

@vafl vafl commented Sep 16, 2019

Issue #, if available:

Description of changes:

Include a quantile function for distributions.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@szha
Copy link
Member

szha commented Sep 16, 2019

Job PR-314/1 is complete.
Docs are uploaded to http://gluon-ts-staging.s3-accelerate.dualstack.amazonaws.com/PR-314/1/index.html

@szha
Copy link
Member

szha commented Sep 16, 2019

Job PR-314/2 is complete.
Docs are uploaded to http://gluon-ts-staging.s3-accelerate.dualstack.amazonaws.com/PR-314/2/index.html

@codecov-io
Copy link

codecov-io commented Sep 16, 2019

Codecov Report

Merging #314 into master will increase coverage by 40.08%.
The diff coverage is 96.82%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #314       +/-   ##
===========================================
+ Coverage   40.45%   80.54%   +40.08%     
===========================================
  Files         142      142               
  Lines        7966     8024       +58     
===========================================
+ Hits         3223     6463     +3240     
+ Misses       4743     1561     -3182
Impacted Files Coverage Δ
src/gluonts/distribution/uniform.py 92.45% <100%> (+25.78%) ⬆️
src/gluonts/distribution/laplace.py 100% <100%> (+36.73%) ⬆️
src/gluonts/distribution/box_cox_tranform.py 83.11% <100%> (+26.36%) ⬆️
...c/gluonts/distribution/transformed_distribution.py 95.06% <100%> (+57.74%) ⬆️
src/gluonts/distribution/piecewise_linear.py 100% <100%> (+52.47%) ⬆️
src/gluonts/distribution/gaussian.py 93.1% <100%> (+28.95%) ⬆️
src/gluonts/distribution/distribution.py 81.94% <80%> (+26.72%) ⬆️
src/gluonts/support/util.py 72.65% <93.33%> (+31.94%) ⬆️
src/gluonts/dataset/artificial/_base.py 36.67% <0%> (+1.43%) ⬆️
src/gluonts/core/exception.py 62.5% <0%> (+2.08%) ⬆️
... and 100 more

@@ -223,6 +230,12 @@ def cdf(self, x: Tensor) -> Tensor:
"""
raise NotImplementedError()

def quantile(self, level: Tensor) -> Tensor:
r"""
Returns the quantile corresponding to the passed level
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to document level here as well as the return value (shape and so on)

def quantile(self, level: Tensor) -> Tensor:
F = self.F
# we consider level to be an independent axis and so expand it
# to shape (num_levels, 1, 1, ...)
Copy link
Contributor

Choose a reason for hiding this comment

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

For example, this expansion here is a bit counterintuitive if one reasons in terms of numpy’s broadcasting

Copy link
Contributor

Choose a reason for hiding this comment

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

But yeah, I guess we should be looking at how mxnet does broadcasting :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we may need to iterate a bit on this. For now I assume the simplest case where level is a 1d array and the method returns a tensor with (num_levels, ...DISTRIBUTION SHAPE...). I documented this in the base class.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense, thanks

@szha
Copy link
Member

szha commented Sep 16, 2019

Job PR-314/3 is complete.
Docs are uploaded to http://gluon-ts-staging.s3-accelerate.dualstack.amazonaws.com/PR-314/3/index.html

@vafl vafl requested review from lostella and removed request for benidis September 16, 2019 08:22
@vafl vafl merged commit 96ea70d into awslabs:master Sep 16, 2019
@vafl vafl deleted the quantile_function branch October 9, 2019 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants