Watch out for confusion:
Obtaining a pseudo-random float using the built-in random_float/0 function
?- X is random_float(). X = 0.9494465703010132. % or ?- X is random_float. X = 0.8947004522094781.
Obtaining a pseudo-random integer using the built-in random/1 FUNCTION
" random/1 called in an arithmetic function context "
?- X is random(0xFFFF). X = 48881.
" random/1 called in a predicate context "
This actually just calls random_float/0:
?- random(X). X = 0.03479878770414104.
You also have other nice predicates like:
?- random_between(5,100,X). X = 46. % same as ?- random(5,100,X). X = 23. % also works with floats: ?- random(0.5,0.8,X). X = 0.7333403405858778.
?- (maybe -> write("heads"); write("tails")).
There is random_member/0, nice for raffles:
?- random_member(X,[1,2,3,4,5,6]). X = 2.
As said, for better (but still pseudo-random) numbers, use:
?- crypto_n_random_bytes(5,Bytes). Bytes = [222, 115, 198, 244, 228].
The appropriate OpenSSL man page for that would be (I think), "man RAND_bytes":
Still need more bytes?
On Unix you may also directly get your bytes from the files /dev/random (blocks waiting for randomness from system activity) and /dev/urandom (does not block but emits pseudo-random bytes if there is not enough randomness from system activity)
Extreme alternative & programming fun: Use the HTTP connector to get your random bytes from Internet paid services such as https://api.random.org/json-rpc/2