Book Image

Mastering Scientific Computing with R

Book Image

Mastering Scientific Computing with R

Overview of this book

Table of Contents (17 chapters)
Mastering Scientific Computing with R
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Monte Carlo integration


Solving integrals is an important mathematical concept related to areas and other quantities modeled by a function. Informally, a definite integral is defined as the signed area of the region outlined by the function f of a real variable x between a and b. Let's consider a simple function that is integrable between the interval [a, b] defined by the integral:

The Monte Carlo integration method relies on the law of large numbers to approximate the integral using the Mean Value theorem for integrals. If f(x) is continuous on the [a, b] interval, then there must exist a value u in [a, b] such that we can apply the following formula:

This formula can be rewritten as follows:

Since the fundamental theorem of calculus implies F'(x) = f(x), we can rewrite the equation as follows:

The preceding formula is the first mean value theorem, where f(c) is the average value of f(x) on the [a, b] interval. Since we can use Monte Carlo simulation to obtain the average value of f(x) on...