Random Python Monte Carlo function

Asked

Viewed 267 times

0

I need to generate random numbers. An amount of numbers in the range of 10 5 and 10 6 random numbers.

The randint function of the Random library seems to me that it does not have a good degree of randomness when it generates so many repeated numbers. Someone knows a library with a better Random function to be used in mount simulation?

Is it possible to renew the seed of the randint function? In order to have a good degree of randomness on that scale?

  • 1

    Why does the randint function not appear to possess good degree of randomness? If you want more secure random numbers, you can use an encryption library like the pycryptodome.

  • Because after generating many numbers the function starts generating numbers in sequence, and or ,the same number with a very high frequency degree

  • Out of curiosity, how did you determine that the function generates numbers in sequence? Making a quick test, the distribution seems to me very reasonable.

  • This might help, https://stackoverflow.com/q/22639587/3162303

  • Enter the code you are using that is easier to help. You are not using the same seed to generate several of the numbers ?

  • Pedro von, that’s not what I did ,but in this way you will reach the same conclusion : create a vector of size x with values 0 . Vector [x] . Have the Random function select values between 0 and X. Go at the position of the vector equal to the value selected by the Random function and have it add a unit . Repeat this procedure in order of 10 6 . And you will see that some vector positions have much higher values than others . That is, this value was selected much more than the others . not being so in fact random ,to be the values had to be + or - equal .

  • @Vitorbento also gives a very reasonable value. If you post the code that’s driving you to draw those conclusions, maybe we can figure out the problem.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.