# Numerical approximation of multiple integral

asked 2017-11-22 14:05:37 -0500

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I want to numerical integrate:

$$\int_{-\infty}^{A_1} \int_{-\infty}^{A_2-x_1} p(x_1)p(x_2)dx_1dx_2 ,$$ where $p(x_i)$ is a random variable that has a normal distribution with mean $\mu_i$ and standard deviation $\sigma_i$.

I faced with several problems:

1. I can't integrate even this simply integral:

import scipy.stats as st

integrate(st.norm.pdf(x), x)

The result is error: TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

1. How to integrate multiple integrals with different $A_i$.
edit retag close merge delete

Sort by » oldest newest most voted

For numerical integrals in Sage, use numerical_integral. The function integrate is more appropriate for symbolic integration.

sage: import scipy.stats as st
sage: numerical_integral(lambda x : st.norm.pdf(x), (-oo, 0.5))
(0.6914624612740132, 1.580169726891987e-09)


The first component is the value of the integral, and the second component is an error estimate.

As far as i'm aware, Sage does not expose a multi-dimensional numerical integration function. This can be worked around by a nested call to numerical_integral, but it will not be as efficient as it could be for some applications. There are more examples in Mathematical Computation with SageMath, Ch. 14, page 315.

more

Please start posting anonymously - your entry will be published after you log in or create a new account.

## Stats

Asked: 2017-11-22 14:05:37 -0500

Seen: 152 times

Last updated: Nov 23 '17