Time for action – calculating the Gaussian integral

The Gaussian integral is related to the error function (also known as erf in mathematics), but has no finite limits. It evaluates to the square root of pi. Let’s calculate the integral with the quad function.

Calculate the Gaussian integral with the quad function.

print “Gaussian integral”, np.sqrt(np.pi),integrate.quad(lambda x: np.exp(-x**2), -np.inf, np.inf)

The return value is the outcome and its error would be shown as follows:

Gaussian integral 1.77245385091 (1.7724538509055159, 1.4202636780944923e-08)

What just happened?

We calculated the Gaussian integral with the quad function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset