scipy.special.
comb#
- scipy.special.comb(N, k, *, exact=False, repetition=False)[Quelle]#
Die Anzahl der Kombinationen von N Dingen, die auf einmal mit k genommen werden.
Dies wird oft als „N wähle k“ ausgedrückt.
- Parameter:
- Nint, ndarray
Anzahl der Elemente.
- kint, ndarray
Anzahl der ausgewählten Elemente.
- exactbool, optional
Bei ganzen Zahlen, wenn exact False ist, wird die Gleitkomma-Genauigkeit verwendet, andernfalls wird das Ergebnis exakt berechnet.
- repetitionbool, optional
Wenn repetition True ist, wird die Anzahl der Kombinationen mit Wiederholung berechnet.
- Rückgabe:
- valint, float, ndarray
Die Gesamtzahl der Kombinationen.
Siehe auch
binomBinomialkoeffizient, betrachtet als Funktion von zwei reellen Variablen.
Hinweise
Array-Argumente sind nur für den Fall exact=False zulässig.
Wenn N < 0 oder k < 0, wird 0 zurückgegeben.
Wenn k > N und repetition=False, wird 0 zurückgegeben.
Beispiele
>>> import numpy as np >>> from scipy.special import comb >>> k = np.array([3, 4]) >>> n = np.array([10, 10]) >>> comb(n, k, exact=False) array([ 120., 210.]) >>> comb(10, 3, exact=True) 120 >>> comb(10, 3, exact=True, repetition=True) 220