ph_montecarlo

Function summary
montecarlo f interval &key (points 1000) (rand_init #'carlson_init) (rand #'carlson) (seed 95423)
uniform_montecarlo f interval &key (points 1000)
PH_MONTECARLO    [Package]

This package provides some implementations of the Montecarlo method for evaluating integrals.

montecarlo   f interval &key (points 1000) (rand_init #'carlson_init) (rand #'carlson) (seed 95423)  [Function]

Evaluates the integral of f using 'points' points. interval is a cons ( a b ) , where a < b.

uniform_montecarlo   f interval &key (points 1000)  [Function]

Evaluates the integral of f using 'points' points. interval is a cons ( a b ) , where a < b. It doesn't use a random number generator. Instead of using It, It uses that if the number of points is big enough, you can aproximate an uniform distribution by a number of points uniformely distributed between 0 and 1, where x_{i} = 1/(N-1)*i . This works because to calculate the integral we don't need the points appear in a aleatorial way, and we win speed. As an example, integrating sin(x)^2 between 0 and pi in my cmucl linux box takes 7 seconds with the conventional method, and 3 with this. Algorithm contributed by David Sanchez i Gregori.