
frandom(-F)

   Generates a random floating-point number F in the range <0, 1>

Arguments
   F                   Floating-point number or variable.

Type
   Arithmetic

Description

   frandom/1 unifies F with a random floating-point number 0.0 < F < 1.0.
   The numbers generated are uniformly distributed.

   The algorithm used depends on the setting of the 'random_mode'
   flag (see set_flag/2, get_flag/2):

    lcg (default)
        Use a Linear Congruential Generator with a period of 2^31-1.
        This can generate 2^31 of 2^52 possible double floats in the range.
        The sequence is reproducible independently of OS and HW.
        The generator state is local to the calling engine.
    
    xs
        Use a xorshift64* generator with a period of 2^64-1.
        This can generate all 2^52 normal double floats in the range.
        The sequence is reproducible independently of OS and HW.
        The generator state is local to the calling engine.
    
    system
        Use the random() or rand() library function.
        This can generate 2^31 of 2^52 possible double floats in the range.
        The sequence may differ on different machines or OSs.
        The generator state is shared with the whole process.
    

   If it is required that the sequence produced by successive calls of
   frandom/1 be reproducible, seed(Seed) can be called to initialise the
   generator state.



Modes and Determinism
   frandom(-) is det

Examples
   
Success:

    ?- frandom(F1), frandom(F2).
    F1 = 0.794873024241474
    F2 = 0.31575316019158489
    Yes (0.00s cpu)

    ?- set_flag(random_mode, xs).
    Yes (0.00s cpu)

    ?- frandom(F1), frandom(F2).
    F1 = 0.383486609149677
    F2 = 0.26587075689945316
    Yes (0.00s cpu)

    ?- seed(123), frandom(F).
    F = 0.17839240843169679
    Yes (0.00s cpu)

    ?- seed(123), frandom(F).
    F = 0.17839240843169679
    Yes (0.00s cpu)


See Also
   seed / 1, random / 2
