Skip to content

Fix pm.Interpolated moment #5986

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

Merged

Conversation

larryshamalama
Copy link
Member

Closes #5959.

Previously, the moment method of pm.Interpolated was $\sum_{i=1}^N x_i f(x_i)$ given finite x_points and their density values pdf_points. However, this can lead to the aforementioned issue as the distances between points in x_points are not accounted.

The code in this first commit needs to be adjusted for cases where x_points is not strictly increasing. Another commit (or two) should follow to account for this.

@codecov
Copy link

codecov bot commented Jul 19, 2022

Codecov Report

Merging #5986 (bca54ad) into main (2a9e86c) will increase coverage by 2.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5986      +/-   ##
==========================================
+ Coverage   87.31%   89.38%   +2.06%     
==========================================
  Files          73       73              
  Lines       13253    13254       +1     
==========================================
+ Hits        11572    11847     +275     
+ Misses       1681     1407     -274     
Impacted Files Coverage Δ
pymc/distributions/continuous.py 97.89% <100.00%> (+0.10%) ⬆️
pymc/sampling.py 82.41% <0.00%> (+0.11%) ⬆️
pymc/distributions/multivariate.py 92.03% <0.00%> (+0.98%) ⬆️
pymc/parallel_sampling.py 86.79% <0.00%> (+0.99%) ⬆️
pymc/distributions/discrete.py 99.21% <0.00%> (+1.56%) ⬆️
pymc/util.py 77.24% <0.00%> (+2.39%) ⬆️
pymc/printing.py 26.66% <0.00%> (+4.76%) ⬆️
pymc/step_methods/hmc/quadpotential.py 80.69% <0.00%> (+6.93%) ⬆️
pymc/model.py 88.20% <0.00%> (+12.05%) ⬆️
... and 2 more

@larryshamalama larryshamalama marked this pull request as ready for review July 26, 2022 15:11
@larryshamalama
Copy link
Member Author

It turns out that InterpolatedUnivariateSpline from SciPy requires x to be increasing. This PR should be ready for review then :)

@michaelosthege michaelosthege merged commit 7afae2a into pymc-devs:main Jul 26, 2022
@larryshamalama larryshamalama deleted the fix-interpolated-moment branch July 26, 2022 21:16
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.

Interpolated distribution in V4
3 participants