dimanche 2 septembre 2018

Options for creating 1-dimensional arrays of random integers in Python?

Because of the slight differences various methods for generating random numbers, I'm trying to map out all the available options in Python. The example use-case is where we have integers from 0 to 10,000, and want to randomly pick 100. Speed/performance is less interesting than different approaches.

For more context, When Random Numbers Are Too Random has some very nice examples but the codes are C++.

I'm already aware of:

import numpy as np
np.random.randint(0,10000,100)

import random
random.sample(list(range(10000)),100)

import secret
[secret.randbelow(10000) for i in range(100)]

Also there is the python package diversipy which implements several methods that output 1-d arrays.

Additionally I've already looked into:

  • scipy.stats
  • SALib
  • pyDOE
  • sobol & sobol_seq
  • lhs_sudoku

Then there is py-design which creates a python wrapper around a bunch of Fortran 90 codes, but it does not work (which is a shame as it seems to be the most comprehensive implementation).




Aucun commentaire:

Enregistrer un commentaire