The UnitSphereSampler accepts a dimension argument and creates the sample using iteration over an array of the given dimension creating n Gaussian samples. This can be optimised for low order dimensions to remove the use of array iteration, e.g.
becomes for 3D:
The special case of 1D sampling can be handled by returning either 1 or -1 in a vector based on a single bit of the random source.
Optimised versions can be created by adding a factory method to the class: