numpy.random.randint()> est l'une des fonctions permettant d'effectuer un échantillonnage aléatoire dans numpy. Il renvoie un tableau de forme spécifiée et le remplit avec des entiers aléatoires allant de faible (inclus) à élevé (exclusif), c'est-à-dire dans l'intervalle [low, high).>
Syntaxe : numpy.random.randint(low, high=Aucun, size=Aucun, dtype=’l’)
Paramètres :
faible : [int] Entier le plus petit (signé) à tirer de la distribution. Mais, il fonctionne comme l'entier le plus élevé de l'échantillon si high=Aucun.
haut : [int, facultatif] Le plus grand entier (signé) à tirer de la distribution.
taille : [entier ou tuple d'entiers, facultatif] Forme de sortie. Si la forme donnée est, par exemple, (m, n, k), alors m * n * k échantillons sont tirés. La valeur par défaut est Aucun, auquel cas une seule valeur est renvoyée.
type : [facultatif] Type de données de sortie souhaité.
Retour : Tableau d'entiers aléatoires dans l'intervalle
[low, high)>ou un seul de ces entiers aléatoires si la taille n'est pas fournie.décoder le javascript base64
Code #1 :
# Python program explaining> # numpy.random.randint() function> > # importing numpy> import> numpy as geek> > # output array> out_arr>=> geek.random.randint(low>=> 0>, high>=> 3>, size>=> 5>)> print> (>'Output 1D Array filled with random integers : '>, out_arr)> |
>
>Sortir :
variable de référence en Java
Output 1D Array filled with random integers : [1 1 0 1 1]>
Code #2 :
# Python program explaining> # numpy.random.randint() function> > # importing numpy> import> numpy as geek> > > # output array> out_arr>=> geek.random.randint(low>=> 4>, size>=>(>2>,>3>))> print> (>'Output 2D Array filled with random integers : '>, out_arr)> |
>
sélectionner plusieurs tables SQL
>Sortir :
Output 2D Array filled with random integers : [[1 1 0] [1 0 3]]>
Code #3 :
alphabet par chiffres
# Python program explaining> # numpy.random.randint() function> > # importing numpy> import> numpy as geek> > # output array> out_arr>=> geek.random.randint(>2>,>10>, (>2>,>3>,>4>))> print> (>'Output 3D Array filled with random integers : '>, out_arr)> |
>
>Sortir :
Output 3D Array filled with random integers : [[[4 8 5 7] [6 5 6 7] [4 3 4 3]] [[2 9 2 2] [3 2 2 3] [6 8 3 2]]]>