# Monte Carlo Integration with a simple example

How can we do the “Integration”?

In many cases, the integration is not easy in an analytical method.

The Monte Carlo Integration method is a numerical integration method.

Let’s think about the below example.

The goal of this integration is to find the area of pink region.

The key idea of the Monte Carlo integration is to find $\hat{f}}$ to represent $f$. See below.

Then, How can we find the $\hat{f}}$ ? the Monte Carlo Integration method uses “Expectation method” (Average) See below

With the random sampling method, we can get the $\hat{f}$ by calculating the mean value.

This is a very useful way especially for the calculation of Bayesian posterior.

The below is an example of Monte Carlo Integration.

I will solve this problem  $\int^2_{-1}x&space;dx$

>> N=10000;
>> 3*sum(rand(N,1)*3-1)/N

ans =

1.5202

Here $\hat{f}$ is < sum(rand(N,1)*3-1)/N > and the range of the integration is 3.

Then, good luck

For more detail, I recommend to read the below article.

http://web.mit.edu/~wingated/www/introductions/mcmc-gibbs-intro.pdf

—————————————————————————————————————————–

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————————————–