1

The following source code (written by me) generates random numbers between 0 and 1:

def nextRandom(seed):
    m = 233280 # modulus
    a = 9301 # multiplier
    c = 49297 # increment
    x0 = seed # start-value
    return ((a * x0 + c) % m)/m

What modification can I apply to this source code to generate random numbers between -1 and 1?

user366312
  • 16,949
  • 65
  • 235
  • 452
  • 1
    What about `2*(((a * x0 + c) % m)/m) - 1`? But this will probably introduce a bias? – mrzo Mar 13 '20 at 00:33
  • @DarrylG, can u supply me any reference? – user366312 Mar 13 '20 at 00:35
  • @user366312--[reference](https://stackoverflow.com/questions/686353/random-float-number-generation)--check 1st answer to see how floating random numbers are generated in a range from LO to HI from an integer random number generator. – DarrylG Mar 13 '20 at 00:39

0 Answers0