O'Reilly logo

GNU Octave by Jesper Schmidt Hansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

More advanced function programming: Monte Carlo integration

Many scientific problems involve computations of integrals. If f is a scalar function of one variable and integratable, we can write the integral as:

More advanced function programming: Monte Carlo integration

(5.7)

where F(x) is the anti-derivative of f. Calculating the integral of most functions analytically can be a daunting and often impossible task, which is why we turn to the numerical alternative.

There are different ways to compute the integral numerically. Here we will write a function that uses the Monte Carlo method . Later we discuss the other integration methods that come with Octave. Now, assume that f is positive in the interval x ∈ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required