mercredi 28 octobre 2020

generating uniform distribution of integeres with python

I tried to generate an uniform distribution of random integeres on a given interval (it's unimportant whether it contains its upper limit or not) with python. I used the next snippet of code to do so:

propsedPython = np.random.randint(0,32767,proposedIndices.shape[0])%2048
propsedPythonNoMod = np.random.randint(0,2048,proposedIndices.shape[0])
propsedPythonNoModIntegers = np.random.random_integers(0,2048,proposedIndices.shape[0])
propsedPythonNoModRandInt = np.empty(proposedIndices.shape[0])
for i in range(proposedIndices.shape[0]):
    propsedPythonNoModRandInt[i] = randint(0,2048)

Plotting the above distributions producing.enter image description here Could somebody point me in the right direction why these spikes appear in al the different cases and or gives some advice which routine to use to got uniformly distributed random integers?

Thanks a lot!




Aucun commentaire:

Enregistrer un commentaire