aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/rand.erl
AgeCommit message (Collapse)Author
2017-04-21Merge branch 'rand/arbitrary_normal_distributions'Raimo Niskanen
* rand/arbitrary_normal_distributions: rand: Support arbitrary normal distributions Conflicts: lib/stdlib/test/rand_SUITE.erl
2017-04-21Implement Xoroshiro116+ and improve statisticalsRaimo Niskanen
Implement Xoroshiro116+ as 'exrop' with fixes. Deprecate all old algorithms but reincarnate 'exs1024' as 'exs1024s' and 'exsplus' as 'exsp' with fixes. Fixes: * Avoid skew for uniform integers caused by using a simple 'rem' operation for range confinement. Correctness requires retry with new random value for an unfortunate first value. * Implement a correct algorithm that collects enough random bits for ranges larger than the generator's precision. * Fix uniform density for floats by acquiring 53 bits then multiplying with 2.0^(-53) which produces floats on the form N * 2.0^(-53).
2017-04-20rand: Support arbitrary normal distributionsGuilherme Andrade
2017-04-04Clean up documentation and test casesRaimo Niskanen
2017-03-22fixup! Support cryptographically strong rand pluginGuilherme Andrade
Minimize use of guards.
2017-03-22fixup! Support cryptographically strong rand pluginGuilherme Andrade
Fix plugin alg type
2017-03-18Support cryptographically strong rand pluginGuilherme Andrade
2016-11-17Fixup of specs in randDan Gudmundsson
Fixed bad specs introduced in commit ff568b5e818. Also suppress improper_lists warnings.
2016-11-14Add jump functions to rand moduleKenji Rikitake
Jump functions returns the state after performing jump calculation to a rand module internal state, which is equivalent to perform a large number of calls of calculating new states for XorShift*/+ algorithms. This commit add jump functions for exsplus and exs1024 algorithms, and a wrapper function jump/1. The wrapper function will cause error with reason "not_implemented" if the jump function for the algorithm is not implemented. This commit adds following new functionalities: - Add new functions rand:jump/0 and rand:jump/1 - Add the member jump to type alg_handler(), a fun for performing the jump function - Add jump functions for exsplus, equivalent to 2^64 calls - Add jump functions for exs1024, equivalent to 2^512 calls - Revise seed_put/1, seed/1, seed/2 See <https://github.com/erlang/otp/pull/1235#discussion_r86950557> - Add dummy jump function for exs64 calling erlang:error(not_implemented) - Add jump function test cases as follows: * Add Common Test group reference_jump * Add tests for jump/0 to reference_jump_procdict/1 * Rename tests for jump/1 to reference_jump_state/1 * Rename gen_jump/1 to gen_jump_1/1 * Add Common Tests reference_jump_procdict and reference_jump_state to the group reference_jump - Add jump function documentation This commit also changes the Copyright year for Kenji Rikitake's code from 2015 to 2015-2016.
2016-04-28Enhance map specs in erts, stdlib, runtime_toolsMagnus Lång
Using the new type syntax, we can specify which keys are required, and which are optional in a way Dialyzer could use.
2016-02-17stdlib: Add suppression of Dialyzer warningsHans Bolinder
2015-12-07Correct rand:export_seed/0 when there is no prior seedBjörn Gustavsson
According to the documentation, rand:export_seed/0 should return 'undefined' if the seed has not been intialized. However, it will create and return a seed. That means that the following code will not work as expected: case rand:export_seed() of undefined -> rand:seen({1,2,3}); _ -> ok end, rand:uniform(Range)
2015-06-18Change license text to APLv2Bruce Yinhe
2015-04-30stdlib: Document and add normal distributed random value functionDan Gudmundsson
It is needed in various tests. It uses the Ziggurat algorithm, which is the fastest that I know.
2015-04-29stdlib: Add new random functionality/moduleKenji Rikitake
The old random module contains an old algorithm which have flaws and the api requires the user to invoke seed and or checking if seed have been invoked, if a non constant seed is to be used. The api contains the following features: - The user can invoke rand:unform/[0|1] directly and get a non constant seeding. - The api is split in functional and non functional functions, i.e. usage of _s functions will not affect the process dictionary. - The api contains several algorithms with different characteristics and can be extended with new algorithms in the future. - Contains state of the art random number generators. - Default algorithm is taylor made for erlang to be fast on 64bits machines.