samedi 9 décembre 2017

Generating a list of random numbers based on probabilities in numpy

You have a list of n elements. Each element in list is either [0,1,2,3]. There is a 58% chance any given element in the list is a 1, and a 42% (1 - 0.58) chance any given element is [0,2,3].

Using python/numpy, how may I go about generating multiple lists as such?

Bonus: Generalized such that you can easily change the set of numbers in the list (i.e., [0,1,2,3,4,5,6,7,8] instead of [0,1,2,3]).

Thanks




Aucun commentaire:

Enregistrer un commentaire