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

update random method to gaussian form. #549

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

argerlt
Copy link
Contributor

@argerlt argerlt commented Apr 11, 2025

Description of the change

replaces the while loop approach currently used in orix.base.random with the more common gaussian sampling used elsewhere.

functionally identical, but (as shown in #218), is 3 to 5 times faster and removes a `while' loop

Progress of the PR

NOTE: While this DOES test every line, I did not write a unit test to prove random variables are uniformly random, as (to my knowledge) such a test does not exist.

I could potentially:
A) calculate the first few spherical harmonics for 10,000 random rotations and vectors, and show the unimodal term dominates
B) calculate the angular distances with dot_outer for groups of random objects and show the distributions match (ie, everything is equally far from everything else)

However, I tried both and both are slow (a few seconds each) adding to the already considerable testing time, and I'm not sure they protect against anything.

Minimal example of the bug fix or new feature

v = Vector3d.random(10000)
r = Rotation.random(10000)

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • Contributor(s) are listed correctly in __credits__ in orix/__init__.py and in
    .zenodo.json.

@argerlt
Copy link
Contributor Author

argerlt commented Apr 11, 2025

Also, this would close out #218

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.

1 participant