mercredi 1 mars 2023

Python: How to generate a random array only consisting of a specific number of -1, 0, 1?

Is there a standard way in Python to generate an array (of size 15), where precisely three 1s and four -1s are placed randomly and the remaining array entries are 0?

An example for such an array would be

0 0 0 0 1 1 0 -1 1 -1 -1 0 0 0 -1



Aucun commentaire:

Enregistrer un commentaire