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

Resolve inconsistency between bar_with_bootstrapped_uncertainty and df_and_err_from_u_kln #1324

Merged
merged 18 commits into from
Jun 10, 2024

Conversation

badisa
Copy link
Collaborator

@badisa badisa commented Jun 6, 2024

  • bar_with_bootstrapped_uncertainty can return an error of zero when df_and_err_from_u_kln returns a large error. I don't think this is actually an issue in practice, but seems like it would be good to address in case we ever use the error for something.

@badisa badisa marked this pull request as ready for review June 6, 2024 15:18
@badisa badisa requested review from mcwitt and maxentile June 6, 2024 15:18
# regardless, summarize as if normal
ddf = np.std(bootstrap_dfs)
# Take the max of the full error estimate and the bootstrapped error. Summarize as if normal regardless
ddf = max(ddf, np.std(bootstrap_dfs))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@maxentile suggested taking the max of the full bar error vs the bootstrapped error

Copy link
Collaborator

@mcwitt mcwitt Jun 6, 2024

Choose a reason for hiding this comment

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

Just double-checking, is the intent to return NaN here if the all-sample BAR calculation returns NaN for the uncertainty?

(Also might want to use np.maximum instead of max here since the latter has more consistent behavior with NaN inputs: max(1.0, nan) == 1.0 vs. np.maximum(1.0, nan) == nan, though both return NaN if the NaN argument is in the first position)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed in 5fecf57 to do np.maximum. Also per offline changed to call np.nan_to_num(ddf) so that values are set to zero beecb39.

timemachine/fe/bar.py Outdated Show resolved Hide resolved
timemachine/fe/bar.py Outdated Show resolved Hide resolved
timemachine/fe/bar.py Outdated Show resolved Hide resolved
tests/test_bar.py Outdated Show resolved Hide resolved
timemachine/fe/bar.py Outdated Show resolved Hide resolved
timemachine/fe/bar.py Outdated Show resolved Hide resolved
"""
test_ukln = Path(__file__).parent / "data" / "zero_overlap_ukln.npz"
u_kln = np.load(open(test_ukln, "rb"))["u_kln"]
boot_df, boot_df_err = bar_with_pessimistic_uncertainty(u_kln)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: might make test clearer to assert here that the BAR-computed overlap is ~0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Asserts the bar overlap is near zero in 632bbcf

tests/test_bar.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@maxentile maxentile left a comment

Choose a reason for hiding this comment

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

Looks good -- makes sense to pessimize over multiple error estimates if they might be under-estimates in different situations.

Sorry for delayed review -- started reviewing last week but failed to post. Small possible opportunity for increased descriptive precision noted, nothing blocking. (Although the BAR and MBAR estimates coincide in case of 2 states, I think their uncertainty estimates might not, based on https://github.com/choderalab/pymbar/blob/a314f001c9c3bef61e824382a70230f73509f842/pymbar/bar.py#L349-L448 )

tests/test_bar.py Outdated Show resolved Hide resolved
timemachine/fe/bar.py Outdated Show resolved Hide resolved
timemachine/fe/bar.py Outdated Show resolved Hide resolved
@badisa badisa enabled auto-merge (squash) June 10, 2024 20:45
@badisa badisa merged commit ff9cb5f into master Jun 10, 2024
1 check passed
@badisa badisa deleted the task/handle-non-overlapping-ukln branch June 13, 2024 15:13
badisa added a commit that referenced this pull request Jul 16, 2024
badisa added a commit that referenced this pull request Jul 16, 2024
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.

3 participants