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

Fix unit test and posteriors #232

Merged
merged 1 commit into from
Jan 16, 2023
Merged

Conversation

hyanwong
Copy link
Member

@hyanwong hyanwong commented Jan 8, 2023

Previously we claimed to return posteriors that were probabilities but the testing was broken, so we didn't notice that we weren't scaling the posteriors to add up to one (i.e. they weren't actually probabilities). This fixes the problem, but therefore changes the posteriors that are output. I think this is the right thing to do.

@hyanwong hyanwong marked this pull request as draft January 10, 2023 21:09
@hyanwong hyanwong marked this pull request as ready for review January 10, 2023 21:10
@hyanwong hyanwong marked this pull request as draft January 12, 2023 21:00
@hyanwong hyanwong marked this pull request as ready for review January 13, 2023 14:38
@hyanwong
Copy link
Member Author

I coded it up so that the inside_outside function returns the actual posterior value from the method, rather than standardising the values into probabilities (that sum to one), as this might be useful for checking the algorithm, e.g. to see how much the total value changes if we don't normalise.

The conversion to probabilities is then done immediately after the posteriors are returned, in the get_dates() function.

Copy link
Contributor

@nspope nspope left a comment

Choose a reason for hiding this comment

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

LGTM! Only a small semantic quibble regarding "normalised" (I'd try to avoid using as an adjective in the docs when talking about anything that's rescaled but doesn't sum/integrate to 1), and a question regarding the overflow protection.

tsdate/base.py Show resolved Hide resolved
tsdate/core.py Outdated Show resolved Hide resolved
tsdate/core.py Outdated Show resolved Hide resolved
**Bugfixes**

- The returned posteriors when ``return_posteriors=True`` now return actual
probabilities (scaled so that they sum to one) rather than normalised
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of "normalised probabilities" is a bit confusing here, because normalizing a probability distribution typically means scaling such that it sums/integrates to 1; not the sort of under/overflow-protection that is happening here

tests/test_functions.py Show resolved Hide resolved
@hyanwong
Copy link
Member Author

Thanks a lot. I agree about "normalisation" (I'm not sure I named that one). I think "standardised" would be better. I reckon I should change the name of the method to that.

Previously we claimed to return posteriors that were probabilities but the testing was broken, so we didn't notice that we didn't scale the posteriors to add up to one (so they weren't actually probabilities)
@hyanwong
Copy link
Member Author

Merging. Will tackle renaming "normalise" to "standardize" in a followup PR. Thanks a lot for the feedback @nspope

@hyanwong hyanwong merged commit d56c63d into tskit-dev:main Jan 16, 2023
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.

None yet

2 participants