logo

Zufallsstichprobe in Numpy | randint()-Funktion

numpy.random.randint()> ist eine der Funktionen zur Durchführung von Zufallsstichproben in Numpy. Es gibt ein Array mit der angegebenen Form zurück und füllt es mit zufälligen Ganzzahlen von niedrig (inklusive) bis hoch (exklusiv), d. h. im Intervall [low, high).>

Syntax : numpy.random.randint(low, high=None, size=None, dtype=’l’)

Parameter:
niedrig : [int] Niedrigste (vorzeichenbehaftete) Ganzzahl, die aus der Verteilung gezogen werden soll. Sie funktioniert jedoch als höchste Ganzzahl in der Stichprobe, wenn high=None.
hoch : [int, optional] Größte (vorzeichenbehaftete) Ganzzahl, die aus der Verteilung gezogen werden soll.
Größe : [int oder Tupel von ints, optional] Ausgabeform. Wenn die gegebene Form z. B. (m, n, k) ist, werden m * n * k Stichproben gezogen. Der Standardwert ist None. In diesem Fall wird ein einzelner Wert zurückgegeben.
dtyp: [optional] Gewünschter Ausgabedatentyp.



Zurückkehren : Array zufälliger Ganzzahlen im Intervall [low, high)>oder ein einzelnes solches zufälliges int, wenn die Größe nicht angegeben ist.

Code Nr. 1:


Vorteile von Instagram für den persönlichen Gebrauch



Listenknoten

# 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)>

>

>

Ausgabe :

 Output 1D Array filled with random integers : [1 1 0 1 1]>

Code Nr. 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)>

Multiplexer

>

Sortieren Sie ein Array Java
>

Ausgabe :

 Output 2D Array filled with random integers : [[1 1 0] [1 0 3]]>


Code Nr. 3:




# 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)>

>

>

Ausgabe :

Array in Java drucken
 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]]]>