-
-
Notifications
You must be signed in to change notification settings - Fork 984
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
Add function for calculating quantiles of weighed samples. #3340
Conversation
d0aa2af
to
fc00066
Compare
@fehiepsi, I've fixed the testing errors and now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BenZickel looks great! I wish we had designed Pyro for more native support of weighted sets of samples, but this is a step in the right direction.
Could you add a simple unit test of this function, similar to test_quantiles() in tests/ops/test_stats.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just one little comment on Tuple[float]
vs Tuple[float, ...]
The Problem
When calculating distribution quantiles based on samples sampled from a guide it is often desirable to correct for the non-uniform gap between the model log-probability and the guide log-probability (this gap is already computed by the
pyro.infer.importance.Importance
module).Currently there is only support for the below:
pyro.ops.stats.quantile
which interpolates quantiles over the sorted samples.pyro.distributions.empirical.Empirical
which does not support interpolation.The Proposed Solution
Add a function
pyro.ops.stats.weighed_quantile
which supports calculating interpolated quantiles with non-uniform weights. The implementation is similar topyro.ops.stats.quantile
but with different weights generated for each index of the input, according to the indices that sort that specific index.