Full-range Random Number In Python
Solution 1:
If you define a uniform random distribution over an infinite domain, the probability of any value in the domain being chosen is infinitesimal. What you're asking for doesn't make any mathematical sense.
Solution 2:
As it was said before, you can't have uniform distribution over the whole real line, but you can use other random distributions which have real line support. Consider Cauchy distribution. It has 'heavy-tails', which simply means that there is a decent probability of getting very big numbers.
Solution 3:
After the discussion in comments i suggest the following :
>>>m=sys.maxint>>>np.random.uniform(-m,m,5)
array([ -5.32362215e+18, -2.90131323e+18, 5.14492175e+18,
-5.64238742e+18, -3.49640768e+18])
As is said the you can get the max integer with sys.maxint
then you can use np.random.randint
to get a random number between the maxint
and -maxint
.
Solution 4:
As @Asad says, what you are trying is mathematically not quite sound. But what you could do, is the following:
define a very big number (maybe this post helps: What is the range of values a float can have in Python?)
use random.uniform(0, biggestValue) as an approximation for random values according to your needs.
Maybe this is what you are looking for.
Post a Comment for "Full-range Random Number In Python"