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 ∈ ...

Get GNU Octave now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.