help-octave
[Top][All Lists]
Advanced

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

Re: help with double quadrature


From: Juan Pablo Carbajal
Subject: Re: help with double quadrature
Date: Mon, 11 Sep 2017 22:04:12 +0200

On Mon, Sep 11, 2017 at 8:17 PM, Clinton Winant
<address@hidden> wrote:
> I have to evaluate an integral over a triangular area:
> int_0^1 int_0^y [f(x,y)] dx,dy
>
> Initially I though I could use dblquad, but is seems the integration limits
> have to be numbers, not variables.  I have backed of to using quadgk to do
> the inner integral, then summing over all y.  Does anyone know a better way?

Have you consider using Monte Carlo integration?
You can use rejection sampling (you'll get about 50% in the unit
square) or the hit-and-run sampler[1]
The rejection samplers goes something like (assuming your triangle is
defined for (x,y) in [0,1]x[0,1])

triag_boundary =@(x) 1 - x # your triangle
N = 1e6;
xy = rand(N,2);
xy (xy(:,2) > triag_boundary(xy(:,1)),:) = [];
I = sum (f(xy(:,1), xy(:,2))) / N; # this is your integral


[1]: 
https://pdfs.semanticscholar.org/4dfe/8bde57bfe0d27bf48ed4d8e32f4938699392.pdf



reply via email to

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