In Python you can set a range for random number. A specific example would be:
import random
random.uniform(-.001,.001)
Better would be to make a random seed available for example:
import random
random.seed(0)
random.uniform(-.001,.001)
Uses:
For rank performance adding a small random number to a factor would make each bucket have the same number of stocks. Useful for the problem posted here: 'Clustered' ranking output - #7 by Jrinne
With the seed it could be used to select a sub-universe of stocks. Many people do this using mod() now. The problem with mod is that sometimes the sub-universe is very small and can be used only a limited number of times before exhaustion creative uses of mod(). See this link for a discussion of this problem: How to choose a ranking system? A or B - #6 by test_user