Funktion mit Pyplot

Tenferenzu

Banned
Registriert
Okt. 2017
Beiträge
6.473
Hi,
ich stecke hier gerade an etwas vermutlich absolut trivialem fest. Ich möchte folgende Funktion in Python/Pyplot darstellen, komme aber nicht auf den richtigen Nenner.
1692704866644.png


Ich bin einfach einem Tutorial gefolgt und das hat auch soweit geklappt mit folgendem Code:
Python:
import math
from matplotlib import pyplot
import numpy

def f(x,a,b,c):
    return a*x**2+b*x+c

xlist = numpy.linspace(0,100, num=101)
ylist = f(xlist, 2, 25, 4)

Wenn ich das allerdings abwandle auf meine Formel, bekomme ich folgenden Fehler:
TypeError: only size-1 arrays can be converted to Python scalars
Python:
import math
from matplotlib import pyplot
import numpy

def psr(t,tau,n):
    return((1 / tau) * ((t / tau) **( n - 1)) * ((1 / math.factorial(n - 1)) * math.exp(-1 * t / tau)))

print(numpy.linspace(0,100, num=101))
xlist = numpy.linspace(0,100, num=101)
ylist = psr(xlist, 2, 25)
pyplot.plot(xlist, ylist)

Ich bin mir sicher, dass die Lösung des Problems trivial ist aber ich komm einfach nicht drauf :freaky:

Danke schonmal für die Hilfe! :)
 
Hi, das sagt die KI - Teste es mal:


Code:
import numpy as np
from matplotlib import pyplot

def psr(t, tau, n):
    return (1 / tau) * ((t * tau) ** n - 1) * ((1 / np.math.factorial(n - 1)) * np.exp(-1 * t / tau))

xlist = np.linspace(0, 100, num=101)
ylist = psr(xlist, 2, 25)
pyplot.plot(xlist, ylist)
pyplot.show()
 
Da einige gute Foren für Office und Excel weggefallen sind, hilft KI beim Coden sehr gut. Bisher 100% erfolg.
Google hilft auch viel, aber komplexe Themen macht die KI einfach besser.
 
Zurück
Oben