[jira] [Created] (MATH-931) Speed up UnitSphereRandomVectorGenerator for high dimensions
Sean Owen created MATH-931:
Summary: Speed up UnitSphereRandomVectorGenerator for high dimensions
URL: https://issues.apache.org/jira/browse/MATH-931 Project: Commons Math
Issue Type: Improvement
Affects Versions: 3.1.1
Reporter: Sean Owen
I have a small proposal to improve the speed of UnitSphereRandomVectorGenerator. This class picks a random point on the unit n-sphere -- a unit vector, chosen uniformly from all possible directions.
It does so using a rejection process -- generates a random point in the unit n-cube (well, with side lengths 2) and rejects any points outside the unit n-sphere, then normalizes the length. This is correct and works well at low dimension. However the volume of the unit n-sphere compared to the unit n-cube drops exponentially. This method eventually takes an extraordinary amount of time when dimensions get past about 20, since virtually no samples are usable.
For example, here is the time in milliseconds taken to make pick 10 points as a function of dimension up to 20:
It's equally correct, and much faster, to generate these points by picking n standard Gaussians and normalizing. This method takes negligible time even into thousands of dimensions.
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira