[SciPy-User] Optimizing integration routine

josef.pktd@gmai... josef.pktd@gmai...
Mon Nov 22 13:25:10 CST 2010


On Mon, Nov 22, 2010 at 2:15 PM, R. O'Gara <ronogara@yahoo.com> wrote:

> Hi all,
>
> I am interested in calculating many integrals of the form f(x,y,A,B)dxdy,
> hence integrating over x,y given parameters A,B,....
> Since I'm exploring parameter space A,B I was first doing nested for loops,
> i.e.
>
> for iA in listA:
>    for iB in listB:
>        dblquad(f(x,y,iA,iB), etc...)
>
> but the problem is that it just seems to take way too long. Is there a way
> this could be optimized? I figured I could vectorize f and make A, B numpy
> arrays but scipy dbquad would give me "the function does not return a valid
> float" message.
>
> Or would rewriting this in C/Fortran be any more efficient?
>
> Any hints/ideas are appreciated. Thank you for your time
>
>

If you can vectorize, and precision doesn't matter too much, and there are
no memory problems, then I would just calculate with on a grid with 4
dimensions (x,y,iA,iB) and sum over x and y.

Josef




>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20101122/c8eeb9c5/attachment.html 


More information about the SciPy-User mailing list