I wanna fill my array in Julia by positive real numbers. But I found information only how to do it with integers or real numbers (including negatives). Is it possible? Thanks!
CodePudding user response:
You can use any mathematical formula that maps the [0, 1)
range into the [0, inf]
:
For example, if x
is your random variable in the [0, 1)
range (obtained with e.g. rand()
for float data types):
tan(x * pi / 2)
atanh(x)
log(x) ^ 2
-log(x) / x ^ p
(forp
non-negative integer -- it will change the number distribution)
There are many other functions.
Of course the numbers are no longer uniformly distributed, but that is impossible to achieve.