scipy.integrate.quad Präzision bei großen Zahlen
Ich versuche, ein solches Integral (eigentlich cdf der Exponentialverteilung mit seinem pdf) über @ zu berechnescipy.integrate.quad()
:
import numpy as np
from scipy.integrate import quad
def g(x):
return .5 * np.exp(-.5 * x)
print quad(g, a=0., b=np.inf)
print quad(g, a=0., b=10**6)
print quad(g, a=0., b=10**5)
print quad(g, a=0., b=10**4)
Und das Ergebnis ist wie folgt:
(1.0, 3.5807346295637055e-11)
(0.0, 0.0)
(3.881683817604194e-22, 7.717972744764185e-22)
(1.0, 1.6059202674761255e-14)
Alle Versuche, eine große obere Integrationsgrenze zu verwenden, führen zu einer falschen Antwort, obwohl die Verwendung vonnp.inf
löst das Problem.
Similiar Fall wird in @ diskutiescipy Ausgabe # 5428 bei GitHub.
Was muss ich tun, um einen solchen Fehler bei der Integration anderer Dichtefunktionen zu vermeiden?