-
Notifications
You must be signed in to change notification settings - Fork 333
Add randn for arrays of standard gaussian distributed random numbers. #146
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 randn for arrays of standard gaussian distributed random numbers. #146
Conversation
We don't want to compile crate ndarray twice for benchmarks and tests; only once. Tests and benchmarks are outside of the crate.
The new ShapeError is a struct, so that we can stuff more information into it without changing the API.
A .push() loop is not efficient enough; we can do this manually using our knowledge that we will produce exactly as many elements as was preallocated for.
The former will optimize out in some cases where the other won't. Improves `dot` bench in fact.
`Debug` enables much better error messages. We control all implementors, so this is a very safe change.
We're in quick development, so we are sticking with the latest stable rust.
Previous for loop used for the epilogue expanded into an unrolled loop, even if it's a very short loop of 0 to maximally 7 elements.
These should just cut the loop one index earlier. No impact on the result.
Thanks. I'm not promising that we will integrate rand directly like this. It could for example belong to a crate of its own "ndarray-rand" or so. |
This is just a first cut. I agree we need to get the dependencies and design right. And I'll have no choice but to read up on git rebasing... out of time for now, will get back to this, as I need it. BTW, is there a good alternative to depending on rand? |
It's just one commit, so you can use cherry-pick to move it to the correct branch. It's simple, like this #124 (comment) I don't know a better crate than rand.
A new crate ndarray-rand could be hosted by me, it would depend on ndarray and rand, and it provides these constructors. |
Maybe using rand for the gaussian samples is the wrong thing? I wonder if we can do this much more efficiently if we're generating a big set. |
I am not sure what is the significant advantage of avoiding rand as a dependency of ndarray.
|
Created a new pull request with clean history and addressing the points above. |
This time trying to rebase, rather than merge, let me know if I've done it correctly.