0

I'm integrating a log-normal function and I'm encountering some unexpected zeros, so why? My code is:

from numpy import pi, log, exp
import scipy.integrate


# My function (a log-normal function)
def Fbloqueo(Xb, wXb, Xbmed):
    return (
        1 / (wXb * Xb * (2 * pi) ** 0.5) * exp(-1 / 2 * ((log(Xb / Xbmed)) / wXb) ** 2)
    )


# some parameters
Xbmed = 20
wXb = 0.010
Xe = 80
# Integration
Magzfc1, _ = scipy.integrate.quad(Fbloqueo, 2, Xe, args=(wXb, Xbmed))
print(Magzfc1)

The result should be 1, but I'm obtaining zero. This behavior occurs many times and this is a problem because I need to multiply by another function to make a fit to find wXb and Xbmed. Does anybody please could help me to understand the problem with the quad function?

Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
  • Your question looks about the same as https://stackoverflow.com/questions/29179778/scipy-quad-uses-only-1-subdivision-and-gives-wrong-result. A solution is to use `quad(Fbloqueo, 2, Xe, args=(wXb, Xbmed), points=[Xbmed])` – Warren Weckesser Jun 11 '20 at 19:34
  • Thank you so much @WarrenWeckesser. Fixed my problem. It is funny because I find others answers like this: https://stackoverflow.com/questions/31983938/python-3-4-scipy-integrate-quad-dropoff..... – Charlie Vargas Sarmiento Jun 12 '20 at 12:07

0 Answers0