-
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 Rice distribution #4
Conversation
This implementation uses Rician functional forms for all the attributes. However, it is noteworthy that when nu >> sigma, the Rice distribution becomes indistinguishable from a normal distribution with mu=nu,sigma=sigma. There are further details in the wikipedia artical. My own experiments suggest that switching to a normal PDF when nu/sigma > 40 improves numerical stability. Likely this cutoff could be much lower without impacting accuracy. Further study could be beneficial here if we run into numerical issues with this distribution implementation. |
Note there were some breaking changes to the setup-python action for MacOS. This PR will also change the test workflow to support python 3.8/3.9 on macos-13 rather than macos-latest. |
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.
Great job and super clean codes!
log_z, log_nu, log_sigma = torch.log(z), torch.log(nu), torch.log(sigma) | ||
log_a = log_nu - log_sigma | ||
log_b = log_z - log_sigma | ||
ab = torch.exp(log_a + log_b) # <-- argument of bessel functions |
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.
again, any reason why not just:
ab = nu * z / (sigma * sigma)
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.
I learned a lot from your code Kevin, thanks!
going ahead and merging this pr to restore CI and add the Rice distribution. as discussed offline with @minhuanli, the tests in this pr do not assess the validity / accuracy of the implicit reparameterization gradients. we should research a method of testing those cheaply and programmatically across the API. i added #8 to remind us of this shortcoming. |
This PR adds a learnable Rice distribution which is useful in modeling structure factors in X-ray crystallography.