Let say I have sorted array :
ary = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
the goal is to randomly pick a number with HIGHER probability of selecting lower numbers. One way to do that is the following :
ary[ int( rand() * rand() * 10) ]
or even :
ary[ int( rand() * rand() * 11) ]
multiplying random numbers 0 < x < 1, on average will produce smaller numbers.
I was wondering if you know better more robust way to that ? Perfectly the "probability slope" of the chance of selecting number should approximate something like 1/x function or something like that.
hist( [ int(rand() * rand() * 11.) for _ in range(1000) ])
=== why duplicate ???? this is not weighted but distribution like, also not discrete distribution ??
hist(np.random.exponential(size=1000) )
Looks like an option, but how to bound it to 0 .. 10 i.e. pick ary-idx from 0 .. 10