-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 taking expectations wrt smoothed weights #61
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
- Coverage 97.44% 89.59% -7.85%
==========================================
Files 6 7 +1
Lines 274 298 +24
==========================================
Hits 267 267
- Misses 7 31 +24 ☔ View full report in Codecov by Sentry. |
@coderabbitai review |
WalkthroughThe Julia package has been expanded with new statistical capabilities. Specifically, an "expectation.jl" file was introduced, adding an Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- Project.toml
Files selected for processing (3)
- docs/src/api.md (1 hunks)
- src/PSIS.jl (2 hunks)
- src/expectation.jl (1 hunks)
Additional comments: 9
docs/src/api.md (1)
- 9-9: Ensure that the documentation for
PSIS.expectation
is complete and provides accurate usage examples and descriptions.src/PSIS.jl (2)
6-6: Ensure that all necessary functions from
StatsBase
are being used and that there are no unnecessary imports.16-16: Confirm that
expectation.jl
is properly included and that all its dependencies are resolved.src/expectation.jl (6)
1-31: The documentation for the
expectation
function is clear and informative.32-32: The function signature for
expectation
is appropriate for the described functionality.36-53: Good implementation of dimension and axis checks to ensure consistency between
x
andpsis_result.weights
.58-62: Proper use of
StatsBase.AnalyticWeights
for computing weighted expectations.64-66: Correct handling of scalar return values when
values
is a zero-dimensional array.69-73: Effective use of multiple dispatch to handle different types of expectation functions, including quantiles.
This PR adds the API function
expectation
, which allows one to take some expectation wrt to PSIS-smoothed weights. This is the main function needed to compute expectations wrt LOO posteriors, though it is not limited to this application.Some notes:
(draws, [chains, [params...]])
, i.e. it might share the data dimensions. This allows the function to be used for data-dependent scalar expectations e.g.loo_pit
. However, one might have data-independent dimensions with or without data dimensions, e.g. for computing the LOO posterior means of all marginals. Supporting this could require a keyword that specifies which (trailing) dims inx
are unrelated to the data or draws.mean
is on the log-scale. However, this would require us to limit which expectations we can support.Summary by CodeRabbit
New Features
Documentation
Refactor
StatsBase
module to enhance statistical operations within the module.