help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Monte carlo integration


From: Sergio Dominguez
Subject: Re: [Help-gsl] Monte carlo integration
Date: Thu, 22 Apr 2004 11:25:46 +0100
User-agent: Mutt/1.3.28i

> 
> Transform the integral (e.g. to polar coordinates) 
> 
> or,
> 
> use the unit square [-1,1] [-1,1] but make your function return 0
> outside the unit circle (slightly inefficient but easy to implement).
> 
> -- 
> Brian Gough
> 
> Network Theory Ltd,
> Publishing Free Software Manuals --- http://www.network-theory.co.uk/

Thanks for your answer,

When I said that I had done my own implementation (ie, without the GSL) of
it that is actually how I have done it. The point is that in the monte carlo
implementation present in the GSL you do not supply the random numbers
to the algoprithm, but supply the limits and the random number generator. It
is the algorithm itself which generates the numbers with the rng supplied
and takes into account only those which fall within the limits.

Hence, either you set the limits as the square and modify the rng to return
values only inside the circle (as I mentioned in my first email)
either you do not touch the rng and set the limits properly 
(hence, as functions).

Changing to polars is feasible only in this case, but not in the more general
one, I do need to do it in cartesians. 

Actually I have compared my implementation in cartesians against the GSL
integrating in polars (where you can set the limits as constants), but I
need to find how to do it with the GSL and in cartesians.

Thought it would be an easy question, so I am assumming it is my poor English
which is making it more difficult! 

Thanks everyone.

Sergio
-- 
Democracy is a government where you can say what you think even if you
don't think.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]