sympy.stats.Multinomial() Funktion in Python
Mit Hilfe der Methode sympy.stats.Multinomial() können wir mit Multinomial Distribution eine diskrete Zufallsvariable erstellen.
Eine multinomiale Verteilung ist die Wahrscheinlichkeitsverteilung der Ergebnisse eines multinomialen Experiments.
Syntax: sympy.stats.Multinomial (syms, n, p) Parameter: syms: das Symbol n: ist die Anzahl der Versuche, eine positive ganze Zahl p: Ereigniswahrscheinlichkeiten, p> = 0 und p <= 1 Rückgabe: Eine diskrete Zufallsvariable mit Multinomialverteilung
Beispiel 1 :
from
sympy.stats.joint_rv_types
import
Multinomial
from
sympy.stats
import
density
from
sympy
import
symbols, pprint
x1, x2, x3
=
symbols(
'x1, x2, x3'
, nonnegative
=
True
, integer
=
True
)
p1, p2, p3
=
symbols(
'p1, p2, p3'
, positive
=
True
)
M
=
Multinomial(
'M'
,
3
, p1, p2, p3)
multiDist
=
density(M)(x1, x2, x3)
pprint(multiDist)
Ausgabe :
/ x1 x2 x3 | 6 * p1 * p2 * p3 | ---------------- für x1 + x2 + x3 = 3 <x1! * x2! * x3! | | 0 sonst \.
Beispiel 2:
from
sympy.stats.joint_rv_types
import
Multinomial
from
sympy.stats
import
density
from
sympy
import
symbols, pprint
x1, x2, x3
=
symbols(
'x1, x2, x3'
, nonnegative
=
True
, integer
=
True
)
M
=
Multinomial(
'M'
,
4
,
0
,
1
,
0
)
multiDist
=
density(M)(x1, x2, x3)
pprint(multiDist)
Ausgabe :
/ x1 x3 | 24 * 0 * 0 | ----------- für x1 + x2 + x3 = 4 <x1! * x2! * x3! | | 0 sonst \.