If a range is passed into the function, this function will pick a random value between the range limits, without traversing the whole range (thus executing in constant time and constant memory).
Thus these should be (at least roughly) equivalent:
:rand.uniform(n)
1..n |> Enum.random()
Depending on why exactly you want a 'random' number, you might be able to use System.unique_integer/1 as well. The following "returns an integer that is unique in the current runtime instance":
System.unique_integer()
A unique positive integer (which could be useful for generating 'random names'):