Skip to content

Add normal and exponential distributions to core::rand #6098

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

Closed
wants to merge 3 commits into from

Conversation

huonw
Copy link
Member

@huonw huonw commented Apr 28, 2013

(This is only a94c86e, the other two are from #6073.)

Very basic support for sampling from N(0,1) and Exp(1). This is basically my experimentations with the Ziggurat algorithm, and will certainly get reorganised when Lib-rand gets finished.

No tests or anything, other than generating 1 million numbers from each distribution, loading it into R and plotting and performing some basic tests (which passed) i.e. Pearson's chi-squared for the Exp(1) values, and Shapiro-Wilks for the N(0,1) values.

normal-exp

(These will be tested better when the lib rand changes linked above start to happen.)

(Also, it's not hugely relevant, but I noticed that this is about double the speed of R for summing 10000000 samples from the normal distribution, even though the current random-float code is subobtimal.)

No need to merge this if it seems like it's being too hasty.

@catamorphism
Copy link
Contributor

@huonw Needs rebasing :-(

huonw added 3 commits April 30, 2013 08:40
This replaces the wrapper around the runtime RNG with a pure Rust
implementation of the same algorithm. This is faster (up to 5x), and
is hopefully safer.

There is still much room for optimisation: testing by summing 100,000,000
random `u32`s indicates this is about 40-50% slower than the pure C
implementation (running as standalone executable, not in the runtime).
Sample from the normal and exponential distributions using the Ziggurat
algorithm.
@huonw
Copy link
Member Author

huonw commented Apr 29, 2013

@catamorphism done!

@bors bors closed this May 1, 2013
@graydon graydon reopened this May 1, 2013
@graydon graydon closed this May 1, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 9, 2020
Downgrade interior_mutable_const lints to warn by default

This change updates the two lints in the file non_copy_const.rs to be warn by default rather than deny by default. It also updates the known problems for declare_interior_mutable_const to mention some issues that are affected by the lints.

This is a repeat pull request since I botched the first one (rust-lang#6012). Apart from my messing up the commits of that one, I also had a problem where the stderr of the tests didn't change despite me changing both lints to warn by default. Is this normal behaviour for some lints or do I need to adjust the tests to accommodate the change?

fixes rust-lang#5863
changelog: none
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.

5 participants