Suppose you want to generate a number between a and b, you can always do this with this formula:
randomNum = (b-a)*prng.rand + a
So, if you need a number from -8 to +7, then a = -8 and b = 7, and your code will be
randomNum = (7-(-8))*prng.rand + (-8)
which is equivalent
randomNum=15*prng.rand - 8
source
share