# FreeBSD Manual Pages

Random(3) OCaml library Random(3)NAMERandom - Pseudo-random number generators (PRNG).ModuleModule RandomDocumentationModuleRandom:sigendPseudo-random number generators (PRNG).===Basicfunctions===valinit:int->unitInitialize the generator, using the argument as a seed. The same seed will always yield the same sequence of numbers.valfull_init:intarray->unitSame asRandom.initbut takes more data as seed.valself_init:unit->unitInitialize the generator with a random seed chosen in a system-depen- dent way. If/dev/urandomis available on the host machine, it is used to provide a highly random initial seed. Otherwise, a less random seed is computed from system parameters (current time, process IDs).valbits:unit->intReturn 30 random bits in a nonnegative integer.Before3.12.0used a different algorithm (affects all the following functions)valint:int->intRandom.intboundreturns a random integer between 0 (inclusive) andbound(exclusive).boundmust be greater than 0 and less than 2^{30.valint32:Int32.t->Int32.tRandom.int32boundreturns a random integer between 0 (inclusive) andbound(exclusive).boundmust be greater than 0.valnativeint:Nativeint.t->Nativeint.tRandom.nativeintboundreturns a random integer between 0 (inclusive) andbound(exclusive).boundmust be greater than 0.valint64:Int64.t->Int64.tRandom.int64boundreturns a random integer between 0 (inclusive) andbound(exclusive).boundmust be greater than 0.valfloat:float->floatRandom.floatboundreturns a random floating-point number between 0 andbound(inclusive). Ifboundis negative, the result is negative or zero. Ifboundis 0, the result is 0.valbool:unit->boolRandom.bool()returnstrueorfalsewith probability 0.5 each.===Advancedfunctions======Advancedfunctions======ThefunctionsfrommoduleStatemanipulatethecurrentstateoftherandomgeneratorexplicitly.Thisallowsusingoneorseveraldeter-ministicPRNGs,eveninamulti-threadedprogram,withoutinterferencefromotherpartsoftheprogram.===moduleState:sigendvalget_state:unit->State.tReturn the current state of the generator used by the basic functions.valset_state:State.t->unitSet the state of the generator used by the basic functions. OCamldoc 2017-04-30 Random(3)

NAME | Module | Documentation

Want to link to this manual page? Use this URL:

<https://www.freebsd.org/cgi/man.cgi?query=Random&sektion=3o&manpath=FreeBSD+12.1-RELEASE+and+Ports>