ich sollte ein Programm für eine Poisson-Verteilung schreiben. Leider habe ich aber das Problem, dass im Ablauf meines Programms die entsprechende Funktion nicht ausgeführt wird. Es erscheint aber keine Fehlermeldung. Deshalb konnte ich leider den Fehler nicht finden.
Code: Alles auswählen
lam = 5
def poisson(lam):
el = np.math.exp(-lam)
k = 0
u = np.random.uniform (0,1,n)
pp = el
fact = 1
pow = 1
if u > pp:
while u > pp:
k = k+1
fact = k*fact
pow = lam*pow
pp = pp+ (pow/fact*el)
return k
else:
return k
mfg slomy