Repeatable randomness from a generator value that every function returns alongside its result.
{note, rand} = Rand.pick(Rand.new(42), [:a3, :c4, :e4])
Summary
Functions
True with the given probability, from 0.0 to 1.0, and the next generator.
A number from low up to but not including high, and the next generator.
A whole number from low to high, both included, and the next generator.
The modulus of the generator: every state is below it.
A generator seeded from any term. The same seed gives the same sequence anywhere.
A number from 0.0 up to but not including 1.0, and the next generator.
True one time in n, and the next generator.
One element of list, and the next generator. An empty list gives nil.
The list in a different order, and the next generator.
The generator's bare state moved on one step: a whole number from 0 below modulus/0.
count independent picks from list, and the next generator. The result may repeat an
element.
Types
@type t() :: %TuningFork.Rand{state: integer()}
Functions
True with the given probability, from 0.0 to 1.0, and the next generator.
A number from low up to but not including high, and the next generator.
A whole number from low to high, both included, and the next generator.
@spec modulus() :: pos_integer()
The modulus of the generator: every state is below it.
A generator seeded from any term. The same seed gives the same sequence anywhere.
A number from 0.0 up to but not including 1.0, and the next generator.
@spec one_in(t(), pos_integer()) :: {boolean(), t()}
True one time in n, and the next generator.
One element of list, and the next generator. An empty list gives nil.
The list in a different order, and the next generator.
@spec step(pos_integer()) :: non_neg_integer()
The generator's bare state moved on one step: a whole number from 0 below modulus/0.
@spec take(t(), [term()], non_neg_integer()) :: {[term()], t()}
count independent picks from list, and the next generator. The result may repeat an
element.